Challenge - 5 Problems
PowerShell Linux Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
PowerShell command output on Linux
What is the output of this PowerShell command run on a typical Linux system?
Get-Process | Where-Object { $_.CPU -gt 0 } | Select-Object -First 1 -Property Name,CPUPowerShell
Get-Process | Where-Object { $_.CPU -gt 0 } | Select-Object -First 1 -Property Name,CPUAttempts:
2 left
💡 Hint
Think about common Linux processes that consume CPU and appear in Get-Process.
✗ Incorrect
On Linux, Get-Process lists running processes. systemd is usually running and may have CPU usage above zero. The output is a hashtable-like object showing Name and CPU.
📝 Syntax
intermediate1:30remaining
Correct syntax for reading a file in PowerShell on Linux
Which option correctly reads the contents of a text file named 'log.txt' in the current directory on Linux using PowerShell?
Attempts:
2 left
💡 Hint
PowerShell uses a cmdlet to read file contents, similar to cat but with a different name.
✗ Incorrect
Get-Content is the correct PowerShell cmdlet to read file contents. The other options are invalid or do not exist in PowerShell.
🔧 Debug
advanced2:00remaining
Fix the error in this PowerShell script on Linux
This script is intended to list all files in /tmp and output their names, but it throws an error on Linux. What is the cause?
Get-ChildItem -Path C:\tmp | ForEach-Object { $_.Name }PowerShell
Get-ChildItem -Path C:\tmp | ForEach-Object { $_.Name }Attempts:
2 left
💡 Hint
Linux uses forward slashes in paths, unlike Windows.
✗ Incorrect
The script uses a Windows path 'C:\tmp' which does not exist on Linux. Changing the path to '/tmp' fixes the error.
🚀 Application
advanced2:30remaining
Automate service restart with PowerShell on Linux
You want to restart the 'nginx' service on a Linux system using PowerShell. Which command correctly does this?
Attempts:
2 left
💡 Hint
PowerShell provides cross-platform cmdlets for service management on Linux.
✗ Incorrect
Restart-Service is fully supported on Linux in PowerShell 6+ and uses systemd under the hood to manage services like nginx. Other options use invalid cmdlets, non-PowerShell commands, or unnecessary constructs.
🧠 Conceptual
expert2:00remaining
Understanding PowerShell environment differences on Linux
Which statement best describes a key difference when running PowerShell scripts on Linux compared to Windows?
Attempts:
2 left
💡 Hint
Think about how Linux file systems differ from Windows and how PowerShell integrates with the OS.
✗ Incorrect
Linux file systems are case-sensitive, unlike Windows. PowerShell on Linux can run native Linux commands directly and respects Linux conventions.