Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shortcuts for Mac terminal.


Command Description
Ctrl + A Jump to beginning of line
Ctrl + E Jump to end of line
Ctrl + U Delete text before cursor
Ctrl + K Delete text after cursor
Ctrl + W Delete word before cursor
Ctrl + T Swap last two characters before cursor
Esc + T Swap last two words before cursor
Ctrl + R Search through previous commands
Ctrl + L Clear screen (or Cmd + K)
Ctrl + C Kill current process
Ctrl + D Exit shell

Core Commands

Command Description
cd Move into home directory
cd dir Move into directory
ls List files
ls -l List files with details
ls -a List hidden files
ls -lh List files with human-readable file size
ls -R List files recursively
sudo command Run command as admin
open file Open file
open . Open current directory
top Display active processes
clear Clear screen

Command History

Command Description
history n Display last n commands
Ctrl + R Search through previous commands
!* Use arguments from previous command
!$ Use last argument from previous command
Esc + . Print arguments from previous command
!value Run previous command starting with value
!! Run previous command

File Management

Command Description
touch file Create empty file
pwd Print full path of current directory
cat file Print file to screen
rm file Remove file
rm -i file Remove file with confirmation
rm -f file Remove file without confirmation
cp file file Copy file (original → copy)
cp file dir Copy file into directory
mv file file Rename file (old → new)

Directory Management

Command Description
mkdir dir Create directory
mkdir -p dir/dir Create subdirectory
rmdir dir Remove empty directory
rm -R dir Remove directory with contents


Command Description
more Print to screen in chunks
> file Write to file
>> file Append to file
< file Read from file


Command Description
[command] -h Print help
[command] --help Print help
[command] help Print help
man [command] View manual
whatis [command] Print description

Adapted from:


This comment has been minimized.

Copy link

@mus-naj mus-naj commented Apr 14, 2016

Esc + F = Forward one word
Esc + B = Backward one word

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment