Bash reference
Essential commands
Knowledge of these commands is required to pass both the exercises and exam.
cat: show file contents on terminalcd: change directorycd ~: go to your home foldercd ..: go to parent folder
chmod: change permissionscomm: compare two sorted files line by linecomm -12: only output lines common to both files
cp: copy file/folderdu: calculate file sizedu -h: display file size in a human-readable format
echo: display a line of textgrep: find a regular expression in a text filegrep -E: use extended regular expressionsgrep -v: invert sense of matching, select non-matching linesgrep -o: print only the matched part of a line
gunzip: expand a file that has been compressed in GZ format; replaces the zipped file with the uncompressed filegunzip -c: write unzipped file contents to stdout (useful for piping)
head: output the first lines of a file (by default, the first 10 lines)head -5orhead -n5: print the first 5 lines
less: display the contents of a filels: list directory contentsls -l: use a long listing format, i.e., one file/folder per line with additional information (permissions, owner, size, date modified)ls -a: show all files/folders (i.e., even those starting with.)
man: show the manual for a commandmkdir: create foldermkdir -p: when creating nested folders, also create parent folders
mv: move file/foldernano: edit a text filepasswd: change passwordpwd: output the current working directorysed: filter and transform textsed 's/foo/bar/g': substitute all occurrences offoowithbar(details)
sort: sort lines in a text filessh user@host: connect to a serverhostwith userusertail: output the last lines of a file (by default, the last 10 lines)tail -5ortail -n5: print the last 5 lines
touch: change file timestamp; create empty file if it does not existuniq: omit repeated lines of textwc: print newline, word, and byte counts for each filewc -l: only print the number of lines
wget: download a file
Other commands
These commands are required for the exercises, but less important for the exam.
clear: clear the terminalgzip: compress a filemd5sum: calculate the MD5 checksum of a filesource: run bash commands stored in a text filetr: translate or delete characterstr -d: delete character
zless: scroll through a zipped file
Important concepts
Special symbols
- The
(is called aparenthesis - The
[is called asquared bracket(sometimes onlybracket) - The
{is called acurly bracket(sometimes onlybrace) - The
~is called atilde - The
*is called anasterisk
Useful links
Linux for bioinformatics
- https://bioinformaticsworkbook.org/Appendix/Unix/unix-basics-1.html#gsc.tab=0
- https://bioinformaticsworkbook.org/Appendix/Unix/UnixCheatSheet.html#gsc.tab=0
- https://bioinformatics.uconn.edu/unix-basics/#
- https://decodebiology.github.io/bioinfotutorials/
- https://www.melbournebioinformatics.org.au/tutorials/tutorials/unix/unix/