Info
This page will serve as a collected reference of the commands introduced in the lecture videos and slides. It is not intended to replace the man pages or watching lectures or reading over the slides, but will hopefully help you navigate the commands we have shared.
Info
Some commands have a “relevant flags” section with flags used in lecture/homeworks prior to the current homework. They serve as a place to start looking - but you should still read the man page to see what these flags do. Importantly, this does not include flags we expect you to discover in the “self-discovery” portion of a homework!
Linux Commands¶
Basic Shell Commands¶
Command | Lecture | Description |
---|---|---|
ssh | 01 | Log in to a remote Linux server (e.g., attu ) |
pwd | 01 | Print current working directory |
cd | 01 | Change working directory |
ls | 01 | List files in working directory (relevant flags: -a -l -r ) |
man | 01 | Bring up manual for a command |
exit | 01 | Log out of shell |
xargs | 03 | Converts standard input to command line arguments (relevant flags: -d ) |
tee | 03 | Allows for the output of a command to be redirected to both a file and stdout |
System Commands¶
Command | Lecture | Description |
---|---|---|
clear | 01 | Clears all output from console |
date | 01 | Output the system date |
cal | 01 | Output a text calendar |
uname | 01 | Print information about the current system |
Directory Commands¶
Command | Lecture | Description |
---|---|---|
ls | 01 | List files in working directory |
pwd | 01 | Print current working directory |
cd | 01 | Change working directory |
mkdir | 01 | Make a new directory |
rmdir | 01 | Remove the given directory (must be empty) |
File Commands¶
Command | Lecture | Description |
---|---|---|
cp | 01 | Copy a file (relevant flags: -i ) |
mv | 01 | Move a file (also used to rename files) (relevant flags: -i ) |
rm | 01 | Remove the given file (relevant flags: -f -r ) |
touch | 01 | Create empty file, or change time-modified |
File Examination Commands¶
Command | Lecture | Description |
---|---|---|
cat | 02 | Print contents of a file |
less | 02 | Output file contents, one page |
more | 02 | Output file contents, one page |
head | 02 | Output number of lines of start of file (relevant flags: -n ) |
tail | 02 | Output number of lines of end of file (relevant flags: -n ) |
wc | 02 | Count words, characters, lines in a file (relevant flags: -l -w ) |
Searching and Sorting Commands¶
Command | Lecture | Description |
---|---|---|
grep | 02 | Search given file for pattern (relevant flags: -E -i -v ) |
sort | 02 | Sort input or file, line based (relevant flags: -f -r ) |
uniq | 02 | Strip duplicate adjacent lines |
find | 02 | Search filesystem (relevant flags: -type ) |
cut | 02 | Remove section from each line of file |
Java Commands¶
Command | Lecture | Description |
---|---|---|
javac ClassName.java | 02 | Compile ClassName |
java ClassName | 02 | Run ClassName |
Unix File System¶
Relative Directories¶
Command | Lecture | Description |
---|---|---|
. | 01 | References the working directory |
.. | 01 | References the parent of working directory |
~username | 01 | username's home directory |
~/Desktop | 01 | Your desktop |
Unix File System¶
Command | Lecture | Description |
---|---|---|
/ | 01 | Root directory that contains all directories |
/bin | 01 | Applications/programs (i.e. binaries) |
/dev | 01 | Hardware devices |
/etc | 01 | Configuration files |
/home | 01 | Contains user's home directories |
/proc | 01 | Running programs (processes) |
/tmp, /var | 01 | Temporary files |
/usr | 01 | Universal system resources |
Text Editors¶
Command | Lecture | Description |
---|---|---|
nano | 01 | Very simple editor |
vim | 01 | More advanced text-editor |
emacs | 01 | More advanced text-editor |
Vim Basics¶
Command | Lecture | Description |
---|---|---|
:w | 01 | Write (save) the current file |
:wq | 01 | Write (save) the current file and exit |
:q! | 01 | Quit, ignoring all changes |
i | 01 | Go into insert mode |
Esc | 01 | Go back to normal mode |
hjkl | 01 | Move cursor left, down, up, right |
u | 01 | Undo last change |
x | 01 | Delete character |
Emacs Basics¶
C = control key, M = alt/meta key
Command | Lecture | Description |
---|---|---|
C-x C-f | 01 | Read a file into emacs |
C-x C-s | 01 | Save a file to disk |
C-x C-c | 01 | Exit emacs |
C-s | 01 | Search forward |
C-r | 01 | Search backwards |
C-v | 01 | Scroll to next screen |
M-v | 01 | Scroll to previous screen |
C-x u | 01 | Undo |
Input/Output Redirection and Command Substitution¶
Command | Lecture | Description |
---|---|---|
command < filename | 02 | stdin redirection: execute command and read its standard input from the contents of filename instead of from the console. |
command > filename | 02 | stdout redirection: execute command and redirect its standard output to the given filename |
command 2> filename | 02 | stderr redirection: execute command and redirect its standard error to the given filename |
command 2>&1 | 02 | stderr redirection: execute command and redirect its standard error to standard output |
command 2>&1 > filename | 02 | stdout and stderr redirection: execute command, redirect standard error to standard output, and redirect standard output to filename |
command1 | command2 | 02 | Pipes: execute command1 and send its standard output as standard input to command2. |
command1 ; command2 | 03 | "THEN": Execute command1, then execute command2 |
command1 && command2 | 03 | "AND": Execute command1, and if it succeeds, then execute command2 |
command1 || command2 | 03 | "OR": Execute command1, and if it fails, then execute command2 |
$(command) | 03 | Command substitution: execute command, then place the output string literally into the given context e.g. `javac $(find -name "*.java")` |
Git Commands¶
Command | Lecture | Description |
---|---|---|
git clone url [dir] | 04 | Copy a git repository |
git add file1 file2... | 04 | Adds file contents to staging area |
git stage file1 file2... | 04 | Same as git add |
git commit | 04 | Takes a snapshot of staging area and creates a commit |
git status | 04 | View status of files in working directory and staging area |
git diff | 04 | Show difference between staging area and working directory |
git log | 04 | Show commit history |
git pull | 04 | Fetch from remote repository and try to merge |
git push | 04 | Push local repository to remote repository |
git branch <branch> | 04 | Create a new branch with given name |
git checkout <branch> | 04 | Switch to the given branch |
git switch <branch> | 04 | Switch to the given branch |
git merge feature | 04 | Merges the feature branch into the current branch checked out |
git log --graph --oneline | 04 | View the commit history, and where HEAD and master are located. Flags unnecessary |
Regex Syntax¶
Command | Lecture | Description |
---|---|---|
. | 06 | Matches any character |
^ | 06 | Matches start of line |
$ | 06 | Matches end of line |
\< | 06 | Matches start of word |
\> | 06 | Matches end of word |
\ | 06 | Escape the following character |
-i | 06 | (Flag to grep) Match case insensitively |
| | 06 | Logical or operator (match this character set or that character set) |
* | 06 | Matches zero or more of the preceding character set |
+ | 06 | Matches one or more of the preceding character set |
? | 06 | Matches zero or one of the preceding character set |
() | 06 | Group characters together |
[] | 06 | Character set |
[^] | 06 | Negate character set |
[a-z] | 06 | Matches all lowercase letters |
[A-Z] | 06 | Matches all uppercase letters |
[0-9] | 06 | Matches all digits |
\1 | 06 | Back references the same characters captured in an earlier grouping (specified by the number), up to \9 |
{} | 06 | Specify how many occurrences of a match we want. Can be an exact number (i.e. {N} ) or an inclusive range of numbers (i.e. {MIN,MAX} ). |