Command-line cheatsheet

This is meant to be a quick list of commands that are useful as you’re getting started with the Unix/Linux command-line and various other tools.

In these examples, items in CAPITAL ITALIC represent items that should be replaced, usually with a file or directory name.

Moving around

cd DIR   change to a directory

pwd   Print the present working directory (i.e., where you are)

ls   list the contents of the current directory

Files and directories

touch FILE creates FILE, or updates its modification time if it already exists

rm FILE removes FILE

mkdir DIR creates the directory DIR

rmdir DIR removes the directory DIR

cp SRC DST copies the file SRC to DST

cp /ee/200/public_html/homework/homework_01.txt ./ copies the homework_01.txt file to the current working directory (aka ./).


provide ee200 ASSIGNMENT FILE submits FILE for grading.

Getting started with vim

Run vimtutor from a command prompt, and work through lesson 1.

Moving files between remote computers

scp FILE USER@SERVER:REMOTEFILE copies FILE from your computer to a server.

scp homework_01.txt copies the homework_01.txt file to the remote server, logging in as the user sbell03.

A more useful prompt

The default prompt ( e.g, sunfire62{sbell03}33} ) isn’t very helpful.

You can get a better one by editing the file ~/.cshrc, and putting the following lines at the end:

# Use a nice prompt
# %n is your current username
# %m is the hostname
# %~ shows the current directory, and uses ~ for home
set prompt="%n@%m\:%~> "

For a fancier color version, use this:

# Color prompt
# You can change the last number in each 38;5;## triad to try different colors
# The first two numbers control background and bold
set prompt="%{\e[38;5;9m%}%n%{\e[38;5;15m%}@%{\e[38;5;3m%}%m%{\e[38;5;7m%}\:%{\e[38;5;6m%}%~%{\e[0m%}> "

Git & submission workflow

git clone REPO creates a local copy of a remote repository

git checkout BRANCH switches from one branch to another (e.g., git checkout work switches to work branch)

git add FILE adds FILE to the “staging area”

git commit creates a new commit with the files you’ve added to the staging area

git push pushes new local commits to the remote repository