CMD, PowerShell and Bash are 3 different kinds of CLI (Command Line Interface) Shells.
CMD (Command Prompt):
- CMD, short for Windows Command Prompt, is the default command-line interpreter for Microsoft Windows operating systems.
- CMD operates with pre-built commands like
cd
,copy
,ping
, etc. - The output is in the form of characters, and it treats input and output as text structures.
PowerShell:
- PowerShell is an advanced version of CMD with added functionalities and features.
- Designed for system administrators, it’s a task-based command-line interface based on the .NET Framework. It has a more interactive graphical command-line interface (CLI) and better support for server automation tasks.
- Unlike CMD, PowerShell treats input and output as objects, making it more versatile.
- PowerShell supports creating custom cmdlets and aliases for both CMD and Bash commands.
- PowerShell learning documentation: PowerShell学习文档, PowerShell learning documentation
Bash:
- Bash is a command-line and scripting language primarily used in Unix/Linux-based operating systems. It’s the default shell in most Linux distributions and has been around since the early days of Unix.
- Like CMD, Bash treats input and output as text structures.
- commands cheat sheet: linux-commands-cheat-sheet-pdf.pdf
Compatibility aliases in Windows PowerShell
PowerShell has several aliases that allow UNIX and cmd.exe users to use familiar commands in Windows. The following table show common commands, the related PowerShell cmdlet, and the PowerShell alias:
https://learn.microsoft.com/zh-cn/powershell/scripting/learn/shell/using-aliases?view=powershell-7.4
cmd.exe command | UNIX command | PowerShell cmdlet | PowerShell alias |
---|---|---|---|
cd, chdir | cd | Set-Location | sl, cd, chdir |
cls | clear | Clear-Host | cls, clear |
copy | cp | Copy-Item | cpi, cp, copy |
del, erase, rd, rmdir | rm | Remove-Item | ri, del, erase, rd, rm, rmdir |
dir | ls | Get-ChildItem | gci, dir, ls |
echo | echo | Write-Output | write, echo |
md | mkdir | New-Item | ni |
move | mv | Move-Item | mi, move, mi |
popd | popd | Pop-Location | popd |
pwd | Get-Location | gl, pwd | |
pushd | pushd | Push-Location | pushd |
ren | mv | Rename-Item | rni, ren |
type | cat | Get-Content | c, cat, type |