Skip to main content

Bash to PowerShell: Commands Cheat Sheet

This cheat sheet provides a quick reference of common Bash commands and their PowerShell equivalents.

File & Directory Navigation

DescriptionBash CommandPowerShell EquivalentNotes
List files in current directorylsGet-ChildItem or lsls is an alias in PowerShell, but formatting differs.
List one item per linels -1Get-ChildItem -Name or gci -NameShows only names, one per line.
Show current directorypwdGet-Location or pwdpwd exists as alias.
Change directorycd <destination>Set-Location <destination> or cd <destination>cd is an alias.
Go up one directorycd ..cd ..Works the same in both.

File Viewing

DescriptionBash CommandPowerShell EquivalentNotes
View file contentscat <file>Get-Content <file> or gc <file> or cat <file>gc and cat are aliases.
View first N lineshead -n N <file>Get-Content -TotalCount N <file>N = number of lines.
View last N linestail -n N <file>Get-Content -Tail N <file>N = number of lines.
View file with pagingless <file>Get-Content <file> | more or Get-Content <file> | Out-Host -PagingPowerShell has no native pager.

File & Directory Management

DescriptionBash CommandPowerShell EquivalentNotes
Copy filecp <source> <destination>Copy-Item <source> <destination> or cp <source> <destination>cp is an alias.
Move/rename filemv <source> <destination>Move-Item <source> <destination> or mv <source> <destination>mv is an alias.
Remove filerm <file>Remove-Item <file> or rm <file>rm is an alias.
Create directorymkdir <directory>New-Item -ItemType Directory <directory> or mkdir <directory>mkdir is an alias.
Create empty filetouch <file>New-Item -ItemType File <file>
Delete directory recursivelyrm -r <directory>Remove-Item -Recurse <directory>

Search & Filtering

DescriptionBash CommandPowerShell EquivalentNotes
Find files by namefind . -name <name/pattern>Get-ChildItem -Recurse -Filter <name/pattern>
Search inside filegrep <pattern> <file>Select-String <pattern> <file>Supports regex by default.
Search recursivelygrep -r <pattern> .Select-String -Recurse <pattern> -Path .

System Info & Environment

DescriptionBash CommandPowerShell EquivalentNotes
Show command pathwhich <command>Get-Command <command> | Select-Object SourceShows full path to command.
Show environment variablesprintenvGet-ChildItem Env:
Set environment variableexport <name>="<value>"$Env:<name> = "<value>"
Show single environment variableecho $<name>$Env:<name>

Help & History

DescriptionBash CommandPowerShell EquivalentNotes
Show command helpman <command>Get-Help <command>Add -Online to open in browser.
Show command historyhistoryGet-History or Get-Content (Get-PSReadLineOption).HistorySavePathGet-History shows current session history while Get-Content (Get-PSReadLineOption).HistorySavePath shows the saved history from all sessions.
Clear terminal screenclearClear-Host or clear or clsclear and cls are aliases.

Pipes & Redirection

DescriptionBash CommandPowerShell EquivalentNotes
Pipe output to file (overwrite)<command> > <file><command> | Out-File <file>
Pipe output to file (append)<command> >> <file><command> | Out-File -Append <file>
Pipe to another command<command1> | <command2><command1> | <command2>Works the same, but passes objects instead of text.

Process Management

DescriptionBash CommandPowerShell EquivalentNotes
Show running processesps auxGet-Process
Search processes by nameps aux | grep <name>Get-Process -Name <name>Supports wildcards
Kill process by namekillall <name>Stop-Process -Name <name>Supports wildcards
Kill process by PIDkill <PID>Stop-Process -Id <PID> or kill <PID>kill is an alias.

Permissions

DescriptionBash CommandPowerShell EquivalentNotes
Change permissionschmod 644 <file>(No direct equivalent)Windows uses ACLs instead.
Change ownershipchown user <file>(No direct equivalent)Requires icacls or Set-Acl.