Summary

You are now empowered

With just a handful of commands, you are now all ready to manage files and navigate your way around the command line! Once you get the hang of it, you will find the command line very efficient and often preferable to using Finder (for Mac users).

Command line cheat sheet

As a useful reference, here are all the commands we covered in this recitation, where the text in brackets represents the file or directory you are interested in manipulating:

Command

Description

pwd

print working directory

ls

list contents of the current directory

cd

navigate to your home directory

cd [dir]

navigate to the specified directory

cd ../

navigate “up” one directory, to the parent directory

mkdir [dir]

make a new directory

rmdir [dir]

remove an empty directory

cp [file] [dir]

copy a file to a directory

cp [dir1] [dir2]

copy a directory to a another directory

mv [file] [dir]

move a file to a directory

mv [filename1] [filename2]

rename a file

mv [dir1] [dir2]

move a directory to another directory

rm [file]

remove a file

rm -r [dir]

remove a directory and all contents (use with caution!)

cat [file]

display file to screen (best for small files)

head -n [file]

display first \(n\) lines of a file

tail -n [file]

display last \(n\) lines of a file

Copyright note: In addition to the copyright shown below, this recitation was developed based on materials from Axel Müller.