Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RyanRoberts/4757ce10450f57fd717905b28bd22365 to your computer and use it in GitHub Desktop.
Save RyanRoberts/4757ce10450f57fd717905b28bd22365 to your computer and use it in GitHub Desktop.
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + L Clears the Screen
Ctrl + C Kill whatever you are running

CORE COMMANDS

ls Short listing
ls -l Long listing
ls -a Listing incl. hidden files
ls -lh Long listing with Human readable file sizes
top Displays active processes. Press q to quit
q Exit
clear Clear screen

FILE MANAGEMENT

touch [file] Create new file
ls -l .. Long listing of parent directory
cd ../../ Move 2 levels up
cat Concatenate to screen
rm [file] Remove a file, e.g. rm [file] [file]
rm -i [file] Remove with confirmation
rm -r [dir] Remove a directory and contents
rm -f [file] Force removal without confirmation
rm -i [file] Will display prompt before
cp [file] [newfile] Copy file to file
cp [file] [dir] Copy file to directory
mv [file] [new filename] Move/Rename, e.g. mv -v [file] [dir]

DIRECTORY MANAGEMENT

mkdir -p [dir]/[dir] Create nested directories
rmdir [dir] Remove directory ( only operates on empty directories )
rm -R [dir] Remove directory and contents

PIPES – Allows to combine multiple commands that generate output

more Output content delivered in screensize chunks
> [file] Push output to file, keep in mind it will get overwritten
>> [file] Append output to existing file
< Tell command to read content from a fi

HELP

reset Resets the terminal display
man [command] Show the help for ‘command’
whatis [command] Gives a one-line description of ‘command’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment