Command Line Cheat Sheet (Mac/Linux)

Jenny Judova
2 min readAug 4, 2019

--

This is a quick cheat sheet for commands to be used in the Terminal command line. Personally ‘..’ was my personal favourite discovery. Here is a link to a google sheet with these commands line hacks that you are welcome to add to your GDrive.

Command: pwd
Example: pwd
What it means: Tells you what directory/folder you are in.

Command: cd
Example: cd Desktop/
What it means: Change directory. The command allows you to change the directory.

Command: cd ~
Example: cd ~
What it means: Change directory to home.

Command: cd ..
Example: cd ..
What it means: Go back by one directory.

Command: cd../..
Example: cd../..
What it means: Move up two levels.

Command: ls
Example: ls
What it means: Lists everything in the directory you are viewing.

Command: ls -a
Example: ls -a
What it means: Lists everything in your current directory including all hidden files.

Command: ls -l
Example: ls -l
What it means: Ls -l displays file permissions, sizes and last updated date/time.

Command: touche
Example: touche filename.txt
What it means: Creates a file.

Command: mkdir
Example: mkdir NewFolderName
What it means: Make new directory/folder.

Command: open
Example: open filename.txt
What it means: Open document or file.

Command: cat
Example: cat filename.txt
What it means: Prints what is in the document.

Command: mv
Example: mv FileName/DirectoryName DirectoryName
What it means: Moves file or folder into a folder. Both folders have to be in the same directory.

Command: mv FileName/FolderName ..
Example: mv FileName/FolderName ..
What it means: Moves file or folder up by one directory.

Command: cp
Example: cp FileName CopyFileName
What it means: Copy file.

Command: cp -r
Example: cp -r FolderName CopyFolderName
What it means: Copy folder. ‘-r’ command makes sure that everything within the folder is copied.

Command: rm
Example: rm FileName
What it means: Removes the file. This does not put the file to trash but completely removes it from the computer.

Command: rm -r
Example: rm -r FolderName
What it means: Removes a directory/folder and everything in it.

Command: rmdir
Example: rmdir FolderName
What it means: Removes a directory/folder.

If there are any command-line commands missing please flag them up to me. This post is being constantly updated.

--

--

Jenny Judova

Software Engineer. Previously I was a founder, then I worked for startups, then I looked after the ecosystem for possibly the best London startup hub. Dyslexic.