This document is NOWHERE NEAR COMPREHENSIVE. To learn more, visit Dr. Spielman’s website and see “Resources” –> “Command Line”!

Directory

Path



Fundamental UNIX commands

Note that # are used for comments UNIX, just like in R (and python!)

Command Description Usage
pwd Display the path of the current directory (aka print working directory) pwd # yup that's it!
ls List files and directories in current directory. ls # yup that's it!
ls -l # display long
ls -a # show hidden files
ls -la # display long and show hidden files
cd Change directory cd path/to/where/I/want/to/go


# Go one directory BACK
cd .. # one directory back. We move backwards with ..
cp Copy a file or directory (use cp -r). The original file is NOT changed, like “copy and paste” (cmd+C/cmd+V) Make a copy of oldfile.txt called newfile.txt
cp oldfile.txt newfile.txt

# Make a copy of the directory first_directory to be called second_directory
cp -r first_directory second_directory
mv Move or rename a file or directory. The original file is changed, like “cut and paste” (cmd+X/cmd+V) # RENAME file from oldfile.txt to newfile.txt
mv oldfile.txt newfile.txt

# MOVE oldfile.txt to live in the directory into_this_directory/
cp oldfile.txt into_this_directory/

# MOVE oldfile.txt to live one directory back
cp oldfile.txt ..
touch Create an new (empty) file. touch name-of-the-new-file-you-want-to-make.txt
mkdir Create a new directory/folder (aka make directory) # Create a new folder called new_directory
mkdir new_directory
rm Remove a file or directory (use rm -r). This is PERMANENT!!! # PERMANENTLY delete a file
rm file_I_dont_need.txt

# PERMANENTLY delete a folder
rm -r directory_I_dont_need/
clear Clear screen (can still simply scroll up for past commands! they aren’t gone!). clear # yup that's it!
history View history of recent past commands history # yup that's it!



Shortcuts and symbols

Shortcut/symbol Description
Ctrl+C Kills current process/command. USE THIS WHEN THINGS GET WEIRD!
tab (tab key) autocomplete word
(up arrow) scroll back through previous commands
. Represent the current directory you are in.
.. Represents one directory backwards. For example, the path ../.. means: two directories back.