Command Line Cheatsheet


Task Windows PowerShell Linux/MacOS Bash
Change Working Directory cd [path]
Set-Location [path]
cd [path]
Print Current Working Directory pwd
Get-Location
pwd
List Files in Working Directory ls
Get-ChildItem
ls
List Files in Specific Directory ls [folder_path]
Get-ChildItem [folder_path]
ls [folder_path]
List Hidden Files ls -hidden
Get-ChildItem -hidden
ls --all
ls -a
List Files with Details ls --long
ls -l
List Recursively ls -recurse
Get-ChildItem -recurse
ls -R

File Management

Task Windows PowerShell Linux/MacOS Bash
Delete File rm [path]
Remove-Item [path]
rm [path]
Delete Folder Recursively rm -Recurse [path]
Remove-Item -Recurse [path]
rm -r [path]
Move File mv [source] [destination]
Move-Item [source] [destination]
mv [source] [destination]
Rename File mv [filepath] [filepath_with_new_name],
Move-Item [filepath] [filepath_with_new_name]
Rename-Item [filepath] [new_name]
mv [filepath] [filepath_with_new_name]
Copy File cp [source] [destination]
Copy-Item [source] [destination]
cp [source] [destination]
Copy Directory Recursively cp -Recurse [source] [destination]
Copy-Item -Recurse [source] [destination]
cp -R [source] [destination]
Create Folder mkdir [path]
ni -ItemType directory [path]
New-Item -ItemType directory [path]
mkdir [path]
Create Empty File ni [path]
New-Item [path]
touch [path]
Print Text File to Console cat [file]
Get-Content [file]
cat [file]
Determine File-type file [file]
Create Symbolic Link New-Item -ItemType Junction -Path [link] -Target [file] ln -s [file] [link]
Create Hard Link New-Item -ItemType HardLink -Path [link] -Target [file] ln [file] [link]

Administrative

Services

Task Windows PowerShell Linux
List Services Get-Service systemctl list-units
Service Status Get-Service -Name [service] systemctl status [service]
Start Service Start-Service -Name [service] sudo systemctl start [service]
Stop Service Stop-Service -Name [service] sudo systemctl stop [service]
Restart Service Restart-Service -Name [service] sudo systemctl restart [service]
Enable Service to Run On Boot Set-Service -Name [service] -StartupType Automatic sudo systemctl enable [service]
Disable Service From Running on Boot Set-Service -Name [service] -StartupType Manual sudo systemctl disable [service]

Processes

Task Windows PowerShell MacOS/Linux
List Processes Get-Process ps aux
Stop Process (PID) Stop-Process -Id [PID] kill [PID]
Stop Process (Name) Stop-Process -Name [name] killall [name]

Package Managers

Task winget (Windows) scoop (Windows) chocolatey (Windows) Homebrew (MacOS/Linux) apt (Debian/Ubuntu) DNF (Fedora/RHEL) pacman (Arch Linux) swupd (Clear Linux) Flatpak (Linux) Snap (Linux)
Install Package winget install [package] scoop install [package] choco install [package] brew install [package] sudo apt install [package] sudo dnf install [package] sudo pacman -S [package]
sudo pacman -S [repo]/[package]
sudo swupd bundle-add [package] flatpak install [package] sudo snap install [package]
Uninstall Package winget uninstall [package] scoop uninstall [package] choco uninstall [package] brew uninstall [package] sudo apt remove [package]
sudo apt purge [package]*
sudo dnf remove [package] sudo pacman -Rs [package] sudo swupd bundle-remove [package] flatpak uninstall [package] sudo snap remove [package]
Update Package winget upgrade [package] scoop update [package] choco upgrade [package] brew upgrade [package] sudo dnf upgrade [package] flatpak update [package] sudo snap refresh [package]
Search Packages winget search [query] scoop search [query] choco search [query] brew search [query] apt search [query] sudo dnf search [query] pacman -Ss [query] sudo swupd search [query] flatpak search [query] snap find [query]
Package Information winget show [package] scoop info [query] choco info [package] brew info [package] apt show [package] sudo dnf info [package] pacman -Si [package] flatpak info [package] snap info [package]
Update Package Index/Check for Updates sudo apt update sudo pacman -Sy sudo swupd check-update
Update All Packages winget upgrade --all choco upgrade all brew update sudo apt upgrade
sudo apt dist-upgrade**
sudo dnf upgrade sudo pacman -Su
sudo pacman -Syu***
sudo swupd update flatpak update sudo snap refresh
List Installed Packages winget list scoop list choco list --local-only brew list apt list --installed sudo dnf list installed pacman -Q sudo swupd bundle-list flatpak list snap list

*apt purge uninstalls and removes all configuration files

**apt dist-upgrade updates all packages and replaces obsolete packages with newer replacements

***pacman -Syu combines updating the package index and upgrading all packages

Networking

Task Windows PowerShell MacOS Linux
Show IP Address Get-NetIPAddress
Get-NetIPConfiguration
ifconfig ip address
ip a
ifconfig
View Routing Table Get-NetRoute netstat -rn ip route show
ip r
route
Ping ping [host]
Test-Connection -ComputerName [host]
ping [host] ping [host]
Trace Route Test-NetConnection -ComputerName [host] -TraceRoute traceroute [host] traceroute [host]
DNS Lookup Resolve-DnsName [domain] dig [domain] dig [domain]
View Open Ports lsof -i -P -n lsof -i -P -n

Development

Version Control

Git

GitHub Education Git Cheatsheet

Compilers/Interpreters

Java

Task Command
Compile .java file javac [file]
Run .class file java [classname]
Run .jar program java -jar [jar_file]
Create .jar file jar cfe [jar_file] [main_class] [included_files]
Open Java REPL (JDK9+) jshell

Python

Task Command
Open Python REPL python
Run Python script or .pyc program python [file]
Run library module python -m [module]
Compile Python script to .pyc python -m compileall [script]

Node.js

Task Command
Start a Node.js REPL node
Run a JavaScript file node [file]