Data lookups
Command-line reference
Common CMD, PowerShell, Linux and Git commands and what they do.
44 entries.
| Task | Windows CMD | PowerShell | Linux / macOS |
|---|---|---|---|
| List files | dir | Get-ChildItem | ls -la |
| Change directory | cd folder | Set-Location folder | cd folder |
| Current directory | cd | Get-Location | pwd |
| Make a directory | mkdir name | New-Item -ItemType Directory name | mkdir -p name |
| Delete a file | del file | Remove-Item file | rm file |
| Delete a folder | rmdir /s /q folder | Remove-Item -Recurse -Force folder | rm -rf folder |
| Copy a file | copy a b | Copy-Item a b | cp a b |
| Copy a folder | xcopy /e /i a b | Copy-Item -Recurse a b | cp -r a b |
| Move / rename | move a b | Move-Item a b | mv a b |
| Show file contents | type file | Get-Content file | cat file |
| First lines | (none) | Get-Content file -TotalCount 10 | head -10 file |
| Last lines | (none) | Get-Content file -Tail 10 | tail -10 file |
| Follow a log | (none) | Get-Content file -Wait -Tail 10 | tail -f file |
| Find text in files | findstr "word" *.txt | Select-String "word" *.txt | grep -r "word" . |
| Find files by name | dir /s /b *.log | Get-ChildItem -Recurse -Filter *.log | find . -name "*.log" |
| Create an empty file | type nul > file | New-Item file | touch file |
| Clear the screen | cls | Clear-Host | clear |
| Environment variable | echo %PATH% | $env:PATH | echo $PATH |
| Set a variable | set X=1 | $env:X = "1" | export X=1 |
| Where is a program | where prog | (Get-Command prog).Source | which prog |
| Running processes | tasklist | Get-Process | ps aux |
| Kill a process | taskkill /PID 123 /F | Stop-Process -Id 123 -Force | kill -9 123 |
| Network config | ipconfig /all | Get-NetIPConfiguration | ip addr / ifconfig |
| Test connectivity | ping host | Test-Connection host | ping host |
| Open ports | netstat -ano | Get-NetTCPConnection | ss -tulpn |
| DNS lookup | nslookup domain | Resolve-DnsName domain | dig domain |
| Download a file | curl -O url | Invoke-WebRequest url -OutFile file | curl -O url / wget url |
| Disk space | wmic logicaldisk get size,freespace | Get-PSDrive | df -h |
| File permissions | icacls file | Get-Acl file | chmod 644 file |
| Run as administrator | runas /user:Administrator cmd | Start-Process pwsh -Verb RunAs | sudo command |
| Command history | doskey /history | Get-History | history |
| Help for a command | command /? | Get-Help command | man command |
| Git: clone | git clone url | git clone url | git clone url |
| Git: status | git status | git status | git status |
| Git: stage all | git add . | git add . | git add . |
| Git: commit | git commit -m "msg" | git commit -m "msg" | git commit -m "msg" |
| Git: push | git push origin main | git push origin main | git push origin main |
| Git: pull | git pull | git pull | git pull |
| Git: new branch | git switch -c name | git switch -c name | git switch -c name |
| Git: switch branch | git switch name | git switch name | git switch name |
| Git: history | git log --oneline -10 | git log --oneline -10 | git log --oneline -10 |
| Git: undo local changes | git restore file | git restore file | git restore file |
| Git: what changed | git diff | git diff | git diff |
| Git: stash work | git stash | git stash | git stash |
PowerShell also accepts many Unix-style aliases (ls, cat, rm), but they map to PowerShell cmdlets and do not take the same flags.