Frequently Used Terminal Commands
macOS is built on Unix, which means powerful terminal commands are available for file management, networking, system monitoring, and development tasks.
Below is a structured list of frequently used macOS commands.
To Stop Terminal Process
Ctrl + C→ Stop current processCtrl + Z→ Suspend processCmd + .→ Interrupt process (alternative to Ctrl + C)- ⌘ + Shift + . → Force quit terminal app by modifying the .zshrc to some another name (use with caution)
File & Directory Management
pwd– Print current directoryls– List filesls -la– List all files (including hidden)cd <directory>– Change directorycd ..– Move up one directorymkdir <name>– Create directoryrmdir <name>– Remove empty directoryrm <file>– Remove filerm -rf <directory>– Force remove directorycp <src> <dest>– Copy filemv <src> <dest>– Move or rename filetouch <file>– Create empty fileopen .– Open current folder in Finder
File Viewing & Editing
cat <file>– Display file contentless <file>– View file page by pagehead <file>– Show first 10 linestail <file>– Show last 10 linestail -f <file>– Live file monitoringnano <file>– Open file in Nano editorvim <file>– Open file in Vimcode <file>– Open file in VS Code (if installed)
System Information
whoami– Current userhostname– System hostnameuname -a– System informationsw_vers– macOS versiondate– Current date & timeuptime– System running time
Disk & Storage
df -h– Disk free spacedf -h /– Main drive spacedu -sh .– Current folder sizedu -sh <folder>– Specific folder size
Process Management
top– Live system monitorps aux– List running processeskill <pid>– Kill processkill -9 <pid>– Force kill process
Network Commands
ping <host>– Check connectivityifconfig– Network configurationnetstat -an– Network statisticscurl <url>– Fetch URL contentwget <url>– Download file (if installed)
Package Management (Homebrew)
brew update– Update formulaebrew upgrade– Upgrade packagesbrew install <pkg>– Install packagebrew uninstall <pkg>– Remove packagebrew list– List installed packages
Git Commands (Development)
git clone <repo>– Clone repositorygit status– Check statusgit add .– Stage changesgit commit -m "message"– Commit changesgit push– Push to remotegit pull– Pull updates
Permission & Ownership
chmod +x <file>– Make file executablechmod 755 <file>– Set permissionchown user:group <file>– Change ownership
Environment & Shell
echo $PATH– Show PATH variableexport VAR=value– Set environment variablesource ~/.zshrc– Reload shell configclear– Clear terminal (Shortcut: `Cmd + K`)
To find files larger than a specific size in macOS, use the find command with the -size option.
Find Files Larger Than 2GB (Entire System)
sudo find / -type f -size +2G 2>/dev/null
- sudo → Required to access all directories
- / → Search from root
- -type f → Only files (For directories, use -type d)
- -size +2G → Greater than 2GB
- 2>/dev/null → Hide permission errors
Find Files Larger Than 3GB
sudo find / -type f -size +3G 2>/dev/null
Search Only Inside Home Directory (Safer & Faster)
find ~ -type f -size +2G
Show File Size Along With Name (Sorted by Size)
find ~ -type f -size +2G -exec ls -lh {} ; | sort -k5 -h
Find Top 20 Largest Files (Alternative Method)
sudo du -ah / 2>/dev/null | sort -rh | head -20
Size Units in find
- k → Kilobytes
- M → Megabytes
- G → Gigabytes
Examples:
-size +500M -size +1G -size +5G