Directory Management
pwd
cd [path]
cd ~
cd /
cd -
cd ..
cd ../..
ls
ls -a
ls -l
ls -S
ls -C
cp -r [directory] [path]
ditto [directory] [path]
mv [directory] [path]
rm -r [directory]
rm -rf [directory]
Output current directory.
Go to directory.
Go to home directory.
Go to root directory.
Previously browsed directory.
Go to parent directory.
Go to two-levels-up directory.
View directory contents.
View hidden files.
View detailed list.
Sort ls output by size.
View in multiple columns.
Copy directory.
Copy directory contents.
Move directory.
Delete directory.
Force delete directory.
System
caffeinate
softwareupdate -l
sudo softwareupdate -i -a -R
killall Dock
defaults write com.apple.dock
ResetLaunchPad -bool true; killall
Dock
sudo dscacheutil -flushcache;sudo
killall -HUP mDNSResponder
cd ~/Library/Mobile\
Documents/com~apple~CloudDocs/
sudo shutdown -r now
sudo shutdown -h now
Keep Mac awake.
Check for updates.
Perform updates.
Reset Dock.
Reset LaunchPad.
Flush DNS cache.
Access iCloud documents.
Restart Mac.
Shut down Mac.
Processes
ps -ax
ps aux
top
top -s [seconds]
top -o rsize
top -o cpu
ps -ax | grep [name-or-PID]
kill [PID]
killall [name]
List processes by PID.
See more details for processes.
Real time processes list.
Adjust top refresh rate.
Sort top by RAM memory.
Sort top by CPU.
Find processes.
Kill process.
Kill process by name.
File Size and Disk Space
du
du -s [file1] [file2]
du -h
du -k
du -m | sort -nr
df -h
df -H
See utilized disk space.
See specific files' utilization.
Human-readable format.
Display disk space in kilobytes.
Sort by size (descending order).
Display free disk space.
Free space in powers of 1000.
Permissions
ls -l [file]
ls -ld [path]
chmod [number] [file]
chmod -R [number] [directory]
chown [user]:[group] [file]
chown -R [user]:[group] [path]
View file permissions.
View directory permissions.
Change file permissions.
Change directory permissions.
Change file ownership.
Change directory ownership.
File Management
touch [file]
open [file]
cat [file]
less [file]
head [file]
head -n [x] [file]
nano [file]
echo "[text]" >> [path]/[file]
cat [file] >> [path]/[file]
echo "[text]" > [path]/[file]
cat [file] > [path]/[file]
cp [file] [path]
cp [file] [new-file]
cp [file] [path]/[new-file]
cp “[file]” [path]
cp [file1] [file2] [file3] [path]
cp -i [file] [path]
mv [file] [path]
mv [file] [new-file]
mv [file] [path]/[new-file]
mv -i [file] [path]
mv *.[extension] [path]
rm [file]
rm -i [file]
rm -f [file]
rm [file1] [file2] [file3]
Create empty file.
Open file.
Output file contents.
See file contents page by page.
Output first 10 lines of file.
Print first x lines of file.
Edit file in Nano.
Append text to file.
Append entire file to file.
Overwrite file with text.
Overwrite file with file.
Copy file.
Make copy in directory.
Copy file with different name.
Copy file with spaces in name.
Copy multiple files.
Ask for copy confirmation.
Move file.
Rename file.
Move file and change name.
Ask for move confirmation.
Move all with same extension.
Remove file.
Confirm before removal.
Force remove file.
Remove multiple files.
Shortcuts
Command - N
Shift-Command-W
Command-T
Command-W
Option-Shift-Command-W
Command-+/-
Command-D
Shift-Command-D
Control-A
Control-E
Control-U
Control-K
Option-Left/Right Arrow
Shift-Command- click path
Triple-click the line.
Command-X
Command-C
Option-Shift-Command-C
Command-V
Command-F
Command-E
Command-J
Command-A
Control-Command-F
Command- double-click URL
Command-P
Command-K
Control-Shift-Command-?
Homebrew Commands
brew update
brew upgrade
brew upgrade [formula]
brew pin [formula]
brew unpin [formula]
brew install [formula]
brew uninstall [formula]
brew list --formula
brew list --cask
brew deps [formula]
brew outdated --formula
brew outdated --cask
brew doctor
brew help
brew cleanup
Update formulae.
Upgrade formulae.
Upgrade specific formula.
Prevent formula upgrade.
Unpin formula.
Install formula.
Uninstall formula.
List installed formulae.
List installed casks.
List formula dependencies.
List outdated formulae.
List outdated casks.
Run troubleshooting.
Read Homebrew help.
Perform cleanup.
Search
find [directory] -name “[file]”
find [directory] -name “*txt”
grep "[text]" [file]
[command] | grep "[text]"
grep -rl "[text]" [directory]
Find file in directory.
Find file by incomplete name.
Look for text in file.
Look for text in output.
Look for text in directory files.
ping [hostname-or-IP]
arp -a
traceroute [hostname-or-IP]
ifconfig
ifconfig [network-adapter]
curl -O [URL]/[file]
ssh [user]@[hostname-or-IP]
ssh-keygen
ssh-copy-id -i [PUB-key] [user]
@[hostname-or-IP]
Test remote connection.
View local network devices.
View path of packets.
List network adapters.
See specific network adapter.
Download file.
Connect via SSH.
Generate SSH key.
Copy SSH key to remote
host.
Mac Terminal Commands Cheat Sheet
Basic Commands
Environment Variables
Network
sudo [command] [arguments]
[command1] | [command2]
[command] > /dev/null
echo [text]
history
history -[x]
![x]
!!
[command] --help
man [command]
exit
printenv
echo $[variable]
export PATH=$PATH:[binary]
export [name]=[value]
Run commands as admin.
Pipe command output.
Hide command output.
Print text to output.
List command history.
Limit history to x items.
Run command from history.
Run previous command.
Get help for command.
Read manual for command.
Exit session.
List all environment variables.
View variable value.
Export binary to path.
Export variable.