A quick reference for the macOS terminal. No essays, just the tables.
Navigating the File System
| Command |
Description |
pwd |
Print the current directory path |
ls |
List directory contents |
ls -a |
List everything, including dotfiles |
ls -l |
Long format: permissions, size, dates |
cd directory |
Change to a directory |
cd .. |
Go up one level |
cd - |
Go back to the previous directory |
cd ~ or cd |
Go to the home directory |
mkdir directory |
Create a directory |
rmdir directory |
Remove an empty directory |
rm file |
Remove a file |
rm -r directory |
Remove a directory and its contents |
cp file1 file2 |
Copy a file |
cp -r dir1 dir2 |
Copy a directory and its contents |
mv old new |
Move or rename a file or directory |
Working with Files
| Command |
Description |
touch file |
Create an empty file or update its timestamp |
cat file |
Print the file contents |
more file |
Page through a file, forward only |
less file |
Page through a file, both directions, q quits |
open file |
Open a file with its default macOS app |
nano file |
Edit in nano |
vi file |
Edit in vi |
System Monitoring and Management
| Command |
Description |
top |
Live view of running processes |
htop |
The same, but nicer (brew install htop) |
ps aux |
Snapshot of all running processes |
kill pid |
Stop a process by its ID |
killall name |
Stop every process with that name |
df |
Free disk space per volume (-h for readable) |
du |
Disk usage per directory (-sh * for a summary) |
Network Utilities
| Command |
Description |
ping host |
Check if a host is reachable |
curl url |
Fetch a URL (-I for headers only) |
wget url |
Download a file (brew install wget) |
ssh user@host |
Open a remote shell |
scp file user@host:path |
Copy a file over SSH |
ftp host |
Connect to an FTP server |
File Permissions
| Command |
Description |
chmod permissions file |
Change file permissions, e.g. chmod 755 |
chown user file |
Change the file owner |
chgrp group file |
Change the file group |
Miscellaneous
| Command |
Description |
man command |
Open the manual page for a command |
echo "text" |
Print text to the terminal |
date |
Show the current date and time |
cal |
Show a calendar for the current month |
uptime |
Show how long the machine has been running |
alias name='command' |
Create a shortcut for a command |
That is the whole sheet. man covers everything the tables do not.