0% found this document useful (0 votes)
744 views1 page

Mac Terminal Commands Cheat Sheet PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
744 views1 page

Mac Terminal Commands Cheat Sheet PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Mac Terminal Commands Cheat Sheet

Basic Commands Search File Management System Environment Variables

sudo [command] [arguments] Run commands as admin. find [directory] -name “[file]” Find file in directory. printenv List all environment variables.
touch [file] Create empty file. caffeinate Keep Mac awake.

[command1] | [command2] Pipe command output. find [directory] -name “*txt” Find file by incomplete name. echo $[variable] View variable value.
open [file] Open file. softwareupdate -l Check for updates.

[command] > /dev/null Hide command output. grep "[text]" [file] Look for text in file. export PATH=$PATH:[binary] Export binary to path.
cat [file] Output file contents. sudo softwareupdate -i -a -R Perform updates.

echo [text] Print text to output. [command] | grep "[text]" Look for text in output. export [name]=[value] Export variable.
less [file] See file contents page by page. killall Dock Reset Dock.

history List command history. grep -rl "[text]" [directory] Look for text in directory files. head [file] Output first 10 lines of file. defaults write com.apple.dock Reset LaunchPad.
ResetLaunchPad -bool true; killall
history -[x] Limit history to x items. head -n [x] [file] Print first x lines of file. Dock Shortcuts
![x] Run command from history.
Homebrew Commands nano [file] Edit file in Nano. sudo dscacheutil -flushcache;sudo Flush DNS cache.
killall -HUP mDNSResponder Command - N Open new window.
!! Run previous command. echo "[text]" >> [path]/[file] Append text to file.
brew update Update formulae.
cd ~/Library/Mobile\ Access iCloud documents. Shift - Command - W Close window.
[command] --help Get help for command. cat [file] >> [path]/[file] Append entire file to file. Documents/com~apple~CloudDocs/
brew upgrade Upgrade formulae.
Command - T Open new tab.
man [command] Read manual for command. echo "[text]" > [path]/[file] Overwrite file with text. sudo shutdown -r now Restart Mac.
brew upgrade [formula] Upgrade specific formula.
Command - W Close tab.
exit Exit session. cat [file] > [path]/[file] Overwrite file with file. sudo shutdown -h now Shut down Mac.
brew pin [formula] Prevent formula upgrade.
Option - Shift - Command - W Close all terminal instances.

brew unpin [formula] Unpin formula. cp [file] [path] Copy file.


Command - +/- Make text bigger/smaller.

Network brew install [formula] Install formula. cp [file] [new-file] Make copy in directory. Directory Management Command - D Split window in two panes.

brew uninstall [formula] Uninstall formula. cp [file] [path]/[new-file] Copy file with different name.
ping [hostname-or-IP] Test remote connection. pwd Output current directory. Shift - Command - D Close split pane.

brew list --formula List installed formulae. cp “[file]” [path] Copy file with spaces in name.
arp -a View local network devices. cd [path] Go to directory. Control - A Move insertion to beginning.

brew list --cask List installed casks. cp [file1] [file2] [file3] [path] Copy multiple files.
traceroute [hostname-or-IP] View path of packets. cd ~ Go to home directory. Control - E Move insertion to end.

brew deps [formula] List formula dependencies. cp -i [file] [path] Ask for copy confirmation.
ifconfig List network adapters. cd / Go to root directory. Control - U Delete line.

brew outdated --formula List outdated formulae. mv [file] [path] Move file.
ifconfig [network-adapter] See specific network adapter. cd - Previously browsed directory. Control - K Delete text until line end.

brew outdated --cask List outdated casks. mv [file] [new-file] Rename file.
curl -O [URL]/[file] Download file. cd .. Go to parent directory. Option - Left/Right Arrow Move word-by-word.

brew doctor Run troubleshooting. mv [file] [path]/[new-file] Move file and change name.
ssh [user]@[hostname-or-IP] Connect via SSH. cd ../.. Go to two-levels-up directory. Shift - Command - click path Select entire file path.

brew help Read Homebrew help. mv -i [file] [path] Ask for move confirmation.
ssh-keygen Generate SSH key. ls View directory contents. Triple-click the line. Select entire line.

brew cleanup Perform cleanup. mv *.[extension] [path] Move all with same extension.
ssh-copy-id -i [PUB-key] [user] Copy SSH key to remote ls -a View hidden files. Command - X Cut selection.
@[hostname-or-IP] host. rm [file] Remove file.
ls -l View detailed list. Command - C Copy selection.
File Size and Disk Space rm -i [file] Confirm before removal.
ls -S Sort ls output by size. Option - Shift - Command - C Copy plain text.
Processes rm -f [file] Force remove file.
du See utilized disk space. ls -C View in multiple columns. Command - V Paste selection.
rm [file1] [file2] [file3] Remove multiple files.
ps -ax List processes by PID. du -s [file1] [file2] See specific files' utilization. cp -r [directory] [path] Copy directory. Command - F Find text.

ps aux See more details for processes. du -h Human-readable format. ditto [directory] [path] Copy directory contents. Command - E Find preselected text.

du -k Display disk space in kilobytes.


Permissions Command - J Jump to selected text.
top Real time processes list. mv [directory] [path] Move directory.

top -s [seconds] Adjust top refresh rate. du -m | sort -nr Sort by size (descending order). ls -l [file] View file permissions. rm -r [directory] Delete directory. Command - A Select all.

top -o rsize Sort top by RAM memory. df -h Display free disk space. ls -ld [path] View directory permissions. rm -rf [directory] Force delete directory. Control - Command - F Full screen mode on/off.

top -o cpu Sort top by CPU. df -H Free space in powers of 1000. chmod [number] [file] Change file permissions. Command - double-click URL Open URL.

ps -ax | grep [name-or-PID] Find processes. chmod -R [number] [directory] Change directory permissions. Command - P Print.

kill [PID] Kill process. chown [user]:[group] [file] Change file ownership. Command - K Clear all but current prompt.

killall [name] Kill process by name. chown -R [user]:[group] [path] Change directory ownership. Control - Shift - Command - ? Open man pages.

You might also like