CS 4440 Wiki:
Terminal Cheat Sheet


The following is a brief introduction of terminal commands that you will likely make use of in this course. If you think of any others worth including here, please let us know on Piazza!


pwd: print working directory:

$ pwd                   # Print path of current dir

mkdir: create directory:

$ mkdir dir             # Create directory dir

cd: change directory:

$ cd dir                # Move to directory dir

$ cd ..                 # Move to parent of current directory

$ cd ../..              # Move to parent of parent of current directory

ls: list the contents of a directory:

$ ls                    # Print contents of current directory

$ ls dir                # Print contents of directory dir

rm: permanently delete:

$ rm file               # Remove file

$ rm -r dir             # Recursively delete directory dir and its contents

Working with Files

cp: copying files:

$ cp srcFile dstFile    # Copy srcFile over dstFile

$ cp srcFile dstDir     # Copy srcFile to dstDir

$ cp srcDir/* dstDir    # Copy contents of srcDir into dstDir

cat: print or concatenate files:

$ cat file              # Print the contents of file

$ cat src > dst         # Copy contents of src over dst

$ cat pre suf > new     # Concatenate prefix and suffix into a new file

mv: move files or directories:

$ mv srcFile dstDir     # Move srcFile to dstDir/srcFile

$ mv srcDir dstDir      # Move srcDir to dstDir/srcDir

wget: download from web:

$ wget url.com/srcFile  # Download srcFile to current directory

Working with Archives

tar -xf: extract archive:

$ tar -x src.tar.gz     # Extract archive src to current directory

tar -czvf: generate archive:

$ tar -c dst.tar.gz src # Create archive dst.tar.gz containing src