Back to top

Command Line

Online Resources

Keyboard Shortcuts for Terminal on Mac

Lifewire.com: Mac Terminal Commands

LearnEnough.com: Learn Enough Command Line to Be Dangerous

Common Commands

ls → List

Example:

cd → Change Directory

Example:

cd ~ → Get Back to Root Directory

Example:

cd .. → To Go Back One Level of Folder

Example:

Option/Alt → Click to Move Cursor

Press option/alt and it will turn your flashing cursor into a plus sign.

You can click anywhere you've already typed on that line and the cursor will show up there.

Keyboard Shortcuts

Keyboard Shortcuts for Terminal on Mac

It is useful to learn the keyboard shortcuts so that you don't have to use a mouse.

Ctl + A → Go to Beginning of Line

Ctl + A will take you back to the beginning of the line you were typing

Ctl + E → Go to End of Line

Ctl + A will take you to the end of the line you were typing

Ctl + U → Clear Line

Ctl + U will clear the line you are currently typing. This only works if the cursor is at the end of the line.

↑ ↓ : Cycle Through Previous Commands

↑ ↓ will cycle you through all of the commands you have typed into the terminal.

Creating New Files

mkdir → Make Directory

Example:

(Make sure you are in the folder you want to make the new directory in)

touch → Make New File Inside Directory

Example:

(Make sure you are in the directory you want to make the new file in)

Opening Files

open (start on Windows) → Open File

Example:

(Make sure you are in the directory you want to access the file from)

open -a (start on Windows) → Open File in Specific Program

You can specify which application the file is opened in

Removing / Deleting Files

rm → Remove File

Example:

(Make sure you are in the directory you want to remove the file from)

rm → Remove All of the Files from a Directory

Example:

(Make sure you are in the directory you want to remove the files from)

Removing Folders / Directories

rm → Remove Folder / Directory

Example:

(Make sure you are one folder/directory level up from the one you want to remove)

If it doesn't work, make sure nothing is using the directory you want to remove.

This will remove the folder and all child components within it, and you cannot get it back!