Skip to content

Latest commit

 

History

History
39 lines (36 loc) · 2.97 KB

crib_sheet.md

File metadata and controls

39 lines (36 loc) · 2.97 KB

Crib Sheet: Intro to Unix



Command Translation Examples
cd change directory cd /absolute/path/of/the/directory/
Go to the home directory by typing simply cd or cd ~
Go up (back) a directory by typing cd ..
pwd print working directory pwd
mkdir make directory mkdir newDirectory creates newDirectory in your current directory
Make a directory one level up with mkdir ../newDirectory
cp copy cp file.txt newfile.txt (and file.txt will still exist!)
mv move mv file.txt newfile.txt (but file.txt will no longer exist!)
rm remove rm file.txt removes file.txt
rm -r directoryname/ removes the directory and all files within
ls list ls *.txt lists all .txt files in current directory
ls -a lists all files including hidden ones in the current directory
ls -l lists all files in current directory including file sizes and timestamps
ls -lh does the same but changes file size format to be human-readable
ls ../ lists files in the directory above the current one
ls -lrS lists files sorted by size in reverse
ls -lt lists files sorted by time
ls -lx lists files sorted by file extension
man manual man ls opens the manual for command ls (use q to escape page)
grep global regular
expression parser
grep ">" seqs.fasta pulls out all sequence names in a fasta file
grep -c ">" seqs.fasta counts the number of those sequences
cat concatenate cat seqs.fasta prints the contents of seqs.fasta to the screen (ie stdout)
head head head seqs.fasta prints the first 10 lines of the file
head -n 3 seqs.fasta prints first 3 lines
tail tail tail seqs.fasta prints the last 10 lines of the file
tail -n 3 seqs.fasta prints last 3 lines
wc word count wc filename.txt shows the number of new lines, number of words, and number of characters
wc -l filename.txt shows only the number of new lines
wc -c filename.txt shows only the number of characters
sort sort sort filename.txt sorts file and prints output
uniq unique uniq -u filename.txt shows only unique elements of a list
(must use sort command first to cluster repeats)
Shortcut Use
Ctrl + C kills current process
Ctrl + L clears screen
Ctrl + A Go to the beginning of the line
Ctrl + E Go to the end of the line
Ctrl + U Clears the line before the cursor position
Ctrl + K Clear the line after the cursor
* wildcard character
tab completes word
Up Arrow call last command
. current directory
.. one level up
~ home
> redirects stdout to a file, overwriting file if it already exists
>> redirects stdout to a file, appending to the end of file if it already exists
` `