pwd
pwdPrint working directory — shows where you currently are.
- -P
- Show the real path, resolving symbolic links.
$ pwdPrints e.g. /home/student/sequences
Before Python, most bioinformatics happens in a terminal. Every command below is written the way you will actually use it: what it does, the option flags worth remembering, and an example with sequencing or lab data. The general shape is always command -flags arguments.
These commands do not ask for confirmation by default. Deletion is permanent — there is no trash bin.
mkdir [options] nameMake a new directory.
$ mkdir -p project/data/rawCreates the whole nested path at once.
touch fileCreate an empty file, or update a file's timestamp.
$ touch notes.md results.csvCreates two empty files.
cp [options] source destinationCopy files or directories.
$ cp reads.fastq backup/Copy one file into a folder.
$ cp -rv raw_data/ /mnt/archive/Copy a whole folder, printing progress.
mv [options] source destinationMove or rename files and directories.
$ mv draft.txt final.txtRename a file.
$ mv *.png figures/Move all PNGs into figures/.
rm [options] fileRemove files. Deletion is immediate and permanent.
$ rm -i temp.txtSafe delete with a confirmation prompt.
$ rm -r old_run/Delete a folder and everything inside it.
rmdir directoryRemove a directory only if it is empty — a safer alternative to rm -r.
$ rmdir empty_folderFails harmlessly if the folder has contents.
ln [-s] target linknameCreate a link (shortcut) to a file.
$ ln -s /data/genome.fa genome.faPoint to a big shared file without copying it.
Sequencing and expression files are often huge. Peek at them before opening them in an editor.
cat [options] file...Print a whole file, or join several files together.
$ cat sample.fastaPrint a small file.
$ cat part1.csv part2.csv > all.csvConcatenate two files into one.
less [options] fileScroll through a large file page by page. Press q to quit, / to search.
$ less -S counts.tsvBrowse a wide count matrix without wrapping.
head [-n N] fileShow the first lines of a file (10 by default).
$ head -n 4 reads.fastqShow one FASTQ record.
tail [-n N] fileShow the last lines of a file.
$ tail -f pipeline.logWatch a running analysis log live.
wc [options] fileCount lines, words and characters.
$ wc -l samples.csvHow many rows does my table have?
diff [options] fileA fileBShow the differences between two files.
$ diff -u run1.csv run2.csvCheck whether two runs produced identical output.
The real power of Unix: find the needle without opening the haystack.
grep [options] pattern file...Search for lines matching a pattern.
$ grep -c '^>' sequences.fastaCount sequences in a FASTA file.
$ grep -rn 'TP53' annotations/Find every mention of TP53 with file and line number.
find path [tests] [actions]Search the directory tree for files by name, size, age or type.
$ find . -name "*.fastq.gz"Locate every compressed FASTQ below this folder.
$ find data -type f -size +1GTrack down the files eating your disk quota.
sort [options] fileSort lines of text.
$ sort -t, -k3 -nr expression.csvRank rows by the third (numeric) column.
sort file | uniq [options]Collapse or count adjacent duplicate lines — nearly always used after sort.
$ sort genes.txt | uniq -c | sort -nrFrequency table of gene names, most common first.
cut -d DELIM -f LIST fileExtract columns from a delimited file.
$ cut -d, -f1,3 samples.csvKeep only the sample ID and treatment columns.
sed 's/old/new/g' fileStream editor — find and replace text on the fly.
$ sed 's/U/T/g' rna.txt > dna.txtBack-transcribe RNA to DNA.
awk 'condition { action }' fileColumn-aware mini language for filtering and computing on tables.
$ awk -F, '$3 > 2 {print $1}' de_genes.csvPrint genes with fold-change above 2.
$ awk '{s+=$2} END {print s/NR}' counts.tsvAverage the second column.
Every command reads input and writes output. Connecting them is what turns small tools into an analysis pipeline.
command1 | command2Pipe — send the output of one command into the next.
$ grep '^>' seqs.fa | wc -lCount FASTA headers by piping grep into wc.
command > fileRedirect output to a file. > overwrites, >> appends.
$ python analysis.py > results.txt 2> errors.txtKeep results and errors in separate files.
command | xargs command2Turn a list of items into arguments for another command.
$ find . -name "*.sam" | xargs -I{} gzip {}Compress every SAM file found.
command | tee fileWrite to a file and to the screen at the same time.
$ ./run.sh | tee run.logWatch the run while saving the log.
Each file has read (r), write (w) and execute (x) permissions for the owner, the group and everyone else.
chmod mode fileChange file permissions.
$ chmod +x align.shAllow a shell script to be run with ./align.sh.
chown user:group fileChange the owner or group of a file (usually needs sudo).
$ sudo chown -R student:lab shared_data/Hand a folder over to the lab group.
sudo commandRun a single command with administrator privileges.
$ sudo apt install samtoolsInstall software system-wide.
Useful when a job hangs or the cluster complains that you are out of space.
ps [options]List running processes.
$ ps aux | grep pythonFind your running Python jobs and their PIDs.
topLive view of CPU and memory usage. Press q to quit.
$ top -u $USERCheck how much memory your alignment is using.
kill [signal] PIDStop a process by its process ID.
$ kill -9 48213Terminate a runaway job.
df [options]Show free disk space per filesystem.
$ df -hCheck whether the data partition is full.
du [options] pathShow how much space files and folders use.
$ du -sh */Size of each subfolder — find the space hog.
man commandRead the manual page for any command. The first place to look.
$ man grepFull documentation for grep, including every flag.
historyList the commands you have run recently.
$ history | grep blastRecover that BLAST command you ran last week.
Most sequencing data arrives compressed and lives on a remote server.
tar [options] archive.tar.gz filesBundle many files into one archive, and unpack them again.
$ tar -czvf run1.tar.gz run1/Compress a results folder.
$ tar -xzvf run1.tar.gzUnpack it again.
gzip fileCompress or decompress a single file.
$ gzip -k reads.fastqCompress while keeping the original.
wget URL | curl -O URLDownload files from the internet on the command line.
$ wget -c https://ftp.ensembl.org/genome.fa.gzFetch a reference genome, resumable.
ssh user@hostLog in to a remote machine such as your institute's cluster.
$ ssh student@cluster.uni.eduOpen a shell on the compute cluster.
scp source user@host:destCopy files between your computer and a remote server.
$ scp results.csv student@cluster:~/analysis/Push one file to the cluster.
$ rsync -avz --progress cluster:~/run1/ ./run1/Pull a large folder down safely.
echo textPrint text or the value of a variable.
$ echo $HOMEShow the path to your home directory.
The terminal moves and filters your data; Python analyses it. Try the two-minute demo — no signup required.
Try the demo