macOS Terminal Commands by Importance

Command Stands For Description Example Usage Helpful Tips
Essential Commands
cd Change Directory Change current directory cd /Users/YourName/Documents cd - returns to previous directory
ls List List files/directories ls -l macOS-specific: -G adds color
mkdir Make Directory Create a new directory mkdir NewFolder Nested dirs: mkdir -p parent/child
rm Remove Delete files/directories rm file.txt Recursive delete: rm -r folder
cp Copy Copy files or directories cp file.txt file_copy.txt Use -R for dirs: cp -R folder1/ folder2/
mv Move Move or rename files/directories mv old.txt new.txt Overwrites unless -i used
cat Concatenate Display file content cat file.txt Combine files: cat file1.txt file2.txt > new.txt
pwd Print Working Directory Display current directory path pwd Outputs absolute path
clear Clear Clear terminal screen clear Alternative: Cmd + K
Intermediate Commands
chmod Change Mode Change file/directory permissions chmod +x script.sh chmod 644 file.txt for read/write (owner) + read (others)
chown Change Owner Change file/directory ownership chown YourName file.txt Requires sudo for system files
sudo Superuser Do Execute command as superuser sudo rm -r /System/Files Requires admin password; use cautiously
find Find Find files/directories find . -name "*.txt" Case-insensitive: find . -iname "*.txt"
touch Touch Create empty file or update timestamp touch file.txt Create multiple: touch file1.txt file2.txt
open Open Open files/folders in default app open file.txt Open Finder: open .
ps Process Status List running processes ps aux aux shows all processes
kill Kill Terminate a process by ID kill 1234 Find PID: ps aux | grep process_name
grep Global Regular Expression Print Search for text within files grep "error" log.txt Recursive: grep -r "error" .
nano Nano (editor name) Simple text editor nano file.txt Save: Ctrl+O, Exit: Ctrl+X
man Manual Open command manuals man ls Search: /keyword
Advanced Commands
ln Link Create links between files ln -s file.txt link.txt -s for symbolic link
zip Zip Compress files into zip zip archive.zip file1.txt Recursive: zip -r archive.zip folder
unzip Unzip Extract zipped archives unzip archive.zip Extract to dir: unzip archive.zip -d folder
date Date Display or set system date/time date Format: date "+%Y-%m-%d %H:%M:%S"
df Disk Free Display disk space usage df -h -h for human-readable
du Disk Usage Show directory/file size du -sh /Users/YourName -s summarizes; -h for human-readable
top Table of Processes Display active processes (real-time) top Quit with q
uname Unix Name Display system info uname -a -a shows all details
whoami Who Am I Display current username whoami Useful for scripts
diff Difference Compare differences between files diff file1.txt file2.txt Use -u for unified output
echo Echo Display messages or variables echo "Hello" Use with vars: echo $PATH
pbcopy Pasteboard Copy Copy text to clipboard echo "Text" | pbcopy Paste with pbpaste
pbpaste Pasteboard Paste Paste clipboard content pbpaste > file.txt Combine: pbpaste | grep "keyword"
sed Stream Editor Stream editor for text manipulation sed 's/old/new/g' file.txt In-place: sed -i '' 's/old/new/g' file.txt
sort Sort Sort lines of text sort file.txt Unique lines: sort -u file.txt
tail Tail Display end of a file tail -n 10 file.txt -f for real-time updates
tee Tee (split output) Redirect output to file and screen echo "test" | tee file.txt Useful for logging
vim Vi Improved Advanced terminal text editor vim file.txt Save & quit: :wq
wc Word Count Count lines, words, characters wc -l file.txt -l (lines), -w (words)
alias Alias Create shortcuts for commands alias ll='ls -l' Add to ~/.zshrc for persistence
brew Homebrew Manage Homebrew packages brew install git Install Homebrew first
curl Client URL Transfer data from/to servers curl -O https://example.com/file.txt -L to follow redirects
history History Show command-line history history Filter: history | grep cd
say Say Text-to-speech say "Hello" Change voice: say -v Alex "Hi"
tar Tape Archive Archive files tar -czf archive.tar.gz folder Extract: tar -xzf archive.tar.gz

macOS-Specific Notes

Recommended Classes