One command reference. Three operating systems. Everything developers need to navigate the terminal.

Whether you're working on Windows, macOS, or Linux, knowing your way around the terminal is an essential developer skill.

But there's one annoying problem:

The same task often requires different commands depending on your operating system.

For example:

  • Windows: dir
  • macOS / Linux: ls

And that's just the beginning.

This cheat sheet brings together the most commonly used terminal commands across all three platforms, organized by category so you can quickly find what you need.

Bookmark this page. You'll probably need it again.

1. Terminal Environments

Before we start, understand the difference between these environments:

Operating System Terminal Environment
Windows Command Prompt (CMD)
Windows PowerShell
macOS Terminal (Zsh / Bash)
Linux Terminal (Bash / Zsh)

Important: Windows CMD and PowerShell are different shells. Some commands work in both, while others have completely different syntax.

Throughout this article:

  • CMD = Windows Command Prompt
  • PowerShell = Windows PowerShell
  • macOS / Linux = Unix-like shells

2. Navigation Commands

The first thing you'll learn in any terminal is how to move around.

Task CMD PowerShell macOS / Linux
Show current directory cd Get-Location pwd
List files dir Get-ChildItem ls
List all files, including hidden dir /a Get-ChildItem -Force ls -la
Change directory cd folder Set-Location folder cd folder
Go up one level cd .. cd .. cd ..
Go to home directory cd %USERPROFILE% cd ~ cd ~
Go to root directory cd \ cd \ cd /
Clear terminal cls Clear-Host clear

Practical examples

# Navigate into a project cd my-project # Move one directory up cd .. # Go to your home directory cd ~ # Display the current location pwd 

Note: pwd and ~ are native Unix shell conventions. PowerShell supports them too, but CMD does not.

3. File and Directory Management

Creating, copying, moving, and deleting files are everyday terminal operations.

Task CMD PowerShell macOS / Linux
Create directory mkdir app New-Item -ItemType Directory app mkdir app
Create empty file type nul > file.txt New-Item file.txt -ItemType File touch file.txt
Copy file copy a.txt b.txt Copy-Item a.txt b.txt cp a.txt b.txt
Move file move a.txt folder Move-Item a.txt folder mv a.txt folder
Rename file ren old.txt new.txt Rename-Item old.txt new.txt mv old.txt new.txt
Delete file del file.txt Remove-Item file.txt rm file.txt
Delete directory rmdir folder /s /q Remove-Item folder -Recurse -Force rm -r folder
Remove empty directory rmdir folder Remove-Item folder rmdir folder
Display file contents type file.txt Get-Content file.txt cat file.txt

Useful examples

# Create a project directory mkdir my-app # Create a file touch index.html # Copy a file cp index.html backup.html # Rename a file mv old-name.txt new-name.txt # Display file contents cat package.json 
⚠️ Be careful with deletion commands. Commands such as `rm -rf` and `Remove-Item -Recurse -Force` can permanently delete files and directories. Always verify the target before executing them.

4. Searching for Files and Text

Finding files and searching inside them are essential skills when working with large projects.

Task CMD PowerShell macOS / Linux
Find a file by name where /r . file.txt Get-ChildItem -Recurse -Filter file.txt find . -name "file.txt"
Search text in a file findstr "hello" file.txt Select-String "hello" file.txt grep "hello" file.txt
Search recursively findstr /s "hello" *.txt `Get-ChildItem -Recurse -File \ Select-String "hello"`
Find executable location where node Get-Command node which node
Search command history doskey /history Get-History history

Examples

# Find all JavaScript files find . -name "*.js" # Search for a specific word grep "useState" App.jsx # Search recursively grep -r "TODO" src/ # Find files with a specific extension find . -name "*.tsx" 

5. System Information

Sometimes you need to inspect your machine without opening system settings.

Task CMD PowerShell macOS / Linux
System information systeminfo Get-ComputerInfo uname -a
Operating system ver Get-CimInstance Win32_OperatingSystem cat /etc/os-release (Linux)
Current username whoami whoami whoami
Hostname hostname hostname hostname
Date and time date /t Get-Date date
Environment variables set Get-ChildItem Env: printenv
Display a variable echo %PATH% $env:PATH echo $PATH

Examples

# Check your username whoami # Check your hostname hostname # Display environment variables printenv # Display PATH echo $PATH 

6. Process Management

When an application freezes or a development server refuses to stop, process management becomes important.

Task CMD PowerShell macOS / Linux
List running processes tasklist Get-Process ps aux
Find process by name `tasklist \ findstr node` Get-Process node
Kill process by PID taskkill /PID 1234 /F Stop-Process -Id 1234 -Force kill -9 1234
Kill by process name taskkill /IM node.exe /F Stop-Process -Name node -Force pkill node
Display live processes tasklist Get-Process top
Interactive process monitor Task Manager Get-Process htop (if installed)

Developer example

Imagine your React development server is stuck on port 5173.

First, find the process:

# macOS / Linux lsof -i :5173 

On Windows:

# Find the process using port 5173 Get-NetTCPConnection -LocalPort 5173 

Then terminate the process using its PID:

# Windows PowerShell Stop-Process -Id 1234 -Force 
# macOS / Linux kill 1234 

Replace 1234 with the actual process ID.

7. Networking Commands

Networking commands help you troubleshoot connectivity, inspect IP addresses, and diagnose DNS problems.

Task CMD PowerShell macOS / Linux
Show IP configuration ipconfig Get-NetIPConfiguration ip addr
Detailed IP information ipconfig /all Get-NetIPConfiguration ip addr show
Test connectivity ping google.com Test-Connection google.com ping google.com
DNS lookup nslookup google.com Resolve-DnsName google.com nslookup google.com
Display network connections netstat -ano Get-NetTCPConnection ss -tulnp
Trace network route tracert google.com Test-NetConnection google.com -TraceRoute traceroute google.com
Display routing table route print Get-NetRoute ip route
Flush DNS cache ipconfig /flushdns Clear-DnsClientCache Depends on OS and resolver

Useful examples

# Check internet connectivity ping google.com # Check DNS resolution nslookup github.com # Inspect network routes traceroute google.com 

8. Package Managers

Package managers make installing and updating development tools much easier.

Task Windows macOS Linux
Install Node.js winget install OpenJS.NodeJS brew install node sudo apt install nodejs npm
Install Git winget install Git.Git brew install git sudo apt install git
Install Python winget install Python.Python.3.12 brew install python sudo apt install python3
Update packages winget upgrade --all brew upgrade sudo apt update && sudo apt upgrade
Search packages winget search node brew search node apt search nodejs
Remove package winget uninstall Git.Git brew uninstall git sudo apt remove git

Important: These examples assume Windows Package Manager (winget), Homebrew on macOS, and APT-based Linux distributions such as Ubuntu and Debian.

Other Linux distributions use different package managers, such as dnf or pacman.

9. Git Commands

Git works almost identically across Windows, macOS, and Linux.

Task Command
Check Git version git --version
Initialize repository git init
Clone repository git clone URL
Check status git status
Stage all changes git add .
Commit changes git commit -m "message"
View commit history git log
Create branch git branch feature
Switch branch git switch feature
Create and switch branch git switch -c feature
Pull changes git pull
Push changes git push
List branches git branch
Merge branch git merge feature
View differences git diff

Typical Git workflow

git status git add . git commit -m "Add new feature" git push 

10. Archive and Compression Commands

Working with ZIP and compressed files is another common terminal task.

Task CMD PowerShell macOS / Linux
Create ZIP Not built-in Compress-Archive -Path folder -DestinationPath app.zip zip -r app.zip folder
Extract ZIP Not built-in Expand-Archive app.zip -DestinationPath output unzip app.zip
Create TAR archive tar -cf app.tar folder tar -cf app.tar folder tar -cf app.tar folder
Extract TAR tar -xf app.tar tar -xf app.tar tar -xf app.tar
Extract TAR.GZ tar -xzf app.tar.gz tar -xzf app.tar.gz tar -xzf app.tar.gz

11. Permissions and Administrative Commands

Permissions control who can access, modify, and execute files.

Task CMD PowerShell macOS / Linux
Display file permissions icacls file.txt Get-Acl file.txt ls -l file.txt
Change permissions icacls file.txt /grant User:F icacls file.txt /grant User:F chmod 755 file.txt
Change file owner takeown /f file.txt takeown /f file.txt chown user file.txt
Run as administrator Run CMD as Administrator Start-Process powershell -Verb RunAs sudo command

Permission example

# Give the owner read, write and execute permissions chmod 755 script.sh # Make a script executable for everyone chmod +x script.sh 

Be careful when using administrator privileges or sudo. Elevated commands can modify critical system files.

12. Disk and Storage Commands

Need to check available storage?

Task CMD PowerShell macOS / Linux
Show disk usage wmic logicaldisk get size,freespace (legacy) Get-Volume df -h
Show directory size No simple built-in equivalent Get-ChildItem with size calculation du -sh folder
List disks diskpart Get-Disk lsblk
Check disk chkdsk Repair-Volume fsck (unmounted filesystem)

Note: Disk repair commands often require administrator privileges and should not be run casually.

13. Environment Variables

Environment variables are especially important for developers working with Node.js, React, Docker, and backend applications.

Task CMD PowerShell macOS / Linux
Display PATH echo %PATH% $env:PATH echo $PATH
Set temporary variable set API_KEY=123 $env:API_KEY="123" export API_KEY=123
Display variable echo %API_KEY% $env:API_KEY echo $API_KEY
Remove variable set API_KEY= Remove-Item Env:API_KEY unset API_KEY

Important: These examples set variables only for the current shell session. Permanent environment variables require different configuration methods.

14. Useful Terminal Shortcuts

You don't always need a command. Keyboard shortcuts can save a lot of time.

Shortcut Action
Ctrl + C Interrupt a running command
Ctrl + L Clear the terminal screen (supported shells)
Ctrl + A Move to the beginning of the line
Ctrl + E Move to the end of the line
Ctrl + R Search command history (common Unix shells)
Tab Autocomplete commands and paths
↑ / ↓ Navigate command history
Ctrl + D End input / exit shell (Unix shells)

Shortcut behavior can vary depending on the terminal application and shell.

15. Bonus: Developer-Specific Commands

If you're a frontend or full-stack developer, these commands will probably be part of your daily workflow.

Task Command
Check Node.js version node -v
Check npm version npm -v
Check pnpm version pnpm -v
Install dependencies npm install
Start development server npm run dev
Build project npm run build
Run tests npm test
Install a package npm install package-name
Install dev dependency npm install -D package-name
Remove package npm uninstall package-name
Run a package without installing globally npx package-name
Check Python version python --version
Check Docker version docker --version
List Docker containers docker ps -a
List Docker images docker images

These commands are generally cross-platform, provided the relevant tools are installed.

16. Quick Reference: The Commands You'll Use Most

Here's the compact version for when you don't have time to read the entire article.

Action Windows CMD PowerShell macOS / Linux
List files dir ls ls
Change directory cd cd cd
Current directory cd pwd pwd
Clear screen cls cls clear
Create folder mkdir mkdir mkdir
Delete file del rm rm
Copy file copy cp cp
Move file move mv mv
Show processes tasklist ps ps aux
Kill process taskkill Stop-Process kill
Show IP ipconfig ipconfig ip addr
Find executable where Get-Command which
Display file type cat cat

Final Thoughts

You don't need to memorize every command in this article.

Instead, focus on understanding the patterns:

  • Navigation helps you move around.
  • File commands help you manage projects.
  • Process commands help you troubleshoot applications.
  • Networking commands help you diagnose connectivity.
  • Package managers help you install development tools.
  • Git commands help you manage your code.

Once you understand the concepts, switching between Windows, macOS, and Linux becomes much easier.

The terminal isn't something to be afraid of. It's one of the most powerful tools a developer can learn.

⭐ Save this cheat sheet for later!

Which operating system do you use most for development: Windows, macOS, or Linux?

Share your favorite terminal command in the comments!

terminal #commandline #windows #linux #macos #programming #webdev #beginners #cheatsheet #productivity