Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is PowerShell on Linux?
PowerShell on Linux is a cross-platform command-line shell and scripting language that works on Linux, macOS, and Windows. It lets you automate tasks and manage systems using the same commands and scripts across different operating systems.
Click to reveal answer
beginner
How do you install PowerShell on a Linux system like Ubuntu?
You can install PowerShell on Ubuntu by running these commands:
How do you start PowerShell on Linux after installation?
Open your terminal and type pwsh then press Enter. This launches the PowerShell shell where you can run PowerShell commands and scripts.
Click to reveal answer
intermediate
Can PowerShell scripts written on Windows run on Linux without changes?
Most PowerShell scripts run on Linux without changes because PowerShell is cross-platform. However, scripts that use Windows-specific features like Windows Registry or Windows-only cmdlets may need adjustments.
Click to reveal answer
beginner
What is a simple PowerShell command to list files in the current directory on Linux?
Use Get-ChildItem or its alias ls to list files and folders in the current directory. For example:
Get-ChildItem
This works similarly on Linux and Windows.
Click to reveal answer
Which command starts PowerShell on a Linux terminal?
Abash
Bpowershell.exe
Cpwsh
Dsh
✗ Incorrect
On Linux, PowerShell is started by typing 'pwsh' in the terminal.
What package manager command is used to install PowerShell on Ubuntu?
Aapt install powershell
Byum install powershell
Cpacman -S powershell
Ddnf install powershell
✗ Incorrect
Ubuntu uses 'apt' as its package manager, so 'apt install powershell' installs PowerShell.
Which of these is a PowerShell cmdlet to list directory contents?
Als -l
BGet-ChildItem
Cdir /w
Dcat
✗ Incorrect
'Get-ChildItem' is the PowerShell cmdlet to list files and folders.
True or False: PowerShell on Linux supports Windows Registry commands.
AFalse
BOnly with special modules
COnly on Ubuntu
DTrue
✗ Incorrect
Windows Registry is a Windows-only feature and is not supported on Linux PowerShell.
What is the main benefit of PowerShell being cross-platform?
AIt replaces Bash on Linux.
BIt runs faster on Linux than Windows.
CIt only works on Linux servers.
DYou can use the same scripts on Windows, Linux, and macOS.
✗ Incorrect
Cross-platform means you can run the same PowerShell scripts on different operating systems.
Explain how to install and start PowerShell on a Linux system.
Think about the commands you run in the terminal step by step.
You got /5 concepts.
Describe the advantages and limitations of using PowerShell on Linux compared to Windows.
Consider what works the same and what might be different.
You got /4 concepts.
Practice
(1/5)
1. What command do you use to start PowerShell on a Linux system?
easy
A. pwsh
B. powershell.exe
C. start-ps
D. shellps
Solution
Step 1: Recall the PowerShell start command on Linux
On Linux, PowerShell is started by typing pwsh in the terminal.
Step 2: Compare options with the known command
powershell.exe, start-ps, and shellps are not valid commands to start PowerShell on Linux.
Final Answer:
pwsh -> Option A
Quick Check:
PowerShell start command on Linux = pwsh [OK]
Hint: Remember: 'pwsh' starts PowerShell on Linux terminals [OK]
Common Mistakes:
Typing 'powershell.exe' which is for Windows only
Using 'start-ps' which is not a valid command
Confusing shell names
2. Which of the following is the correct syntax to run a Linux command inside PowerShell on Linux?
easy
A. Run-Command 'ls -l'
B. Invoke-Linux ls -l
C. ls -l
D. Start-Linux ls -l
Solution
Step 1: Understand how Linux commands run in PowerShell on Linux
PowerShell on Linux allows running Linux commands directly by typing them as is, like ls -l.
Step 2: Evaluate each option
Invoke-Linux ls -l, Run-Command 'ls -l', and Start-Linux ls -l are not valid syntax to run Linux commands.
Final Answer:
ls -l -> Option C
Quick Check:
Run Linux commands directly in PowerShell = ls -l [OK]
Hint: Run Linux commands directly without extra syntax in PowerShell [OK]
Common Mistakes:
Adding unnecessary PowerShell cmdlets before Linux commands
Using quotes incorrectly around Linux commands
Assuming Linux commands need special wrappers
3. What will be the output of this PowerShell on Linux command sequence?
But it returns an error: "Get-Process: The term 'Get-Process' is not recognized." What is the likely cause?
medium
A. PowerShell is not installed correctly on Linux
B. You are running the script in the Linux shell, not inside PowerShell
C. The process 'bash' does not exist
D. Get-Process cmdlet is not available on Linux PowerShell
Solution
Step 1: Analyze the error message
The error says 'Get-Process' is not recognized, which usually means the command is run outside PowerShell.
Step 2: Understand environment context
If you run PowerShell commands in the Linux shell (bash), they won't work. You must be inside PowerShell (started with pwsh) to run Get-Process.
Final Answer:
You are running the script in the Linux shell, not inside PowerShell -> Option B
Quick Check:
Run PowerShell cmdlets inside pwsh shell [OK]
Hint: Run PowerShell commands only inside pwsh shell, not bash [OK]
Common Mistakes:
Assuming Get-Process is missing on Linux PowerShell
Thinking the process 'bash' does not exist
Not starting PowerShell before running commands
5. You want to write a PowerShell script on Linux that lists all running processes and filters only those owned by the current user. Which approach is correct?
hard
A. Get-Process | Where-Object { $_.UserName -eq $env:USER }
B. ps -u $USER | pwsh
C. Get-Process | Where-Object { $_.UserName -eq (whoami) }
D. Get-Process | Where-Object { $_.UserName -eq $env:USERNAME }
Solution
Step 1: Identify environment variable for current user in PowerShell on Linux
PowerShell on Linux uses $env:USER to get the current user's name.
Step 2: Check filtering syntax for processes
Filtering processes by Where-Object { $_.UserName -eq $env:USER } correctly compares the process owner to the current user.
Step 3: Evaluate other options
ps -u $USER | pwsh mixes Linux command with PowerShell incorrectly. Get-Process | Where-Object { $_.UserName -eq (whoami) } uses command output that may not match precisely. Get-Process | Where-Object { $_.UserName -eq $env:USERNAME } uses $env:USERNAME which is typically not set on Linux.