Navigation    
Command Function Syntax/example usage
ls list contents ls [OPTIONS] DIRECTORY
pwd print working directory pwd
cd change directory cd ~ or cd #home directory
    cd .. #previous (parent directory)

File/Directory operations

File/Directory operations    
Command Function Syntax/example usage
mkdir make directory mkdir DIRECTORY
cp copy files/directories cp SOURCE DESTINATION
man manual page (help) man COMMAND
mv move files/directories mv SOURCE DESTINATION
touch create file touch FILE
nano edit file nano FILE
less view file (with more options) less FILE
more view file (with less options) more FILE
cat catalog file contents cat FILE
head show first few lines of a file head FILE
tail show last few lines of a file tail FILE
rmdir remove empty directory rmdir DIRECTORY
rm remove file(s) rm FILE

File manipulations

File manipulations    
Command Function Syntax/example usage
grep search a pattern grep [OPTIONS] “PATTERN” FILENAME
sed stream edit a file sed 's/search/replace/g' FILENAME
awk multi-purpose command awk 'PATTERN {ACTION}' FILENAME
tr translate or transliterate a file tr [OPTIONS] “STRING1” “STRING2” < INFILE
wc word count wc FILENAME
sort sort files sort FILE1 > SORTED_FILE1
uniq display unique lines uniq [OPTIONS] INFILE > OUTFILE
diff display difference diff [OPTIONS] FILE1 FILE2
comm display common lines among files comm [OPTIONS] FILE1 FILE2
cut break files vertically based on fields cut –d “DELIMITER” –f NUMBER FILE
split break files horizontally split [OPTIONS] FILENAME
paste combine files side by side paste FILE1 FILE2 > FILE3
join join files based on common field join -t ‘DELIMITER’ -1 N -2 N FILE1 FILE2

Compression/archiving

Compression/archiving    
Command Function Syntax/example usage
zip zip compress zip OUTFILE.zip INFILE.txt
    zip -r OUTDIR.zip DIRECTORY
unzip decompress zipped file unzip ANYTHING.zip
tar archive and compress files/directories tar -czvf OUTFILE.tar.gz DIRECTORY #compress
    tar -xzvf OUTFILE.tar.gz # extract
gzip gzip files gzip SOMEFILE
gunzip decompress gzipped files gunzip SOMEFILE.gz

File permissions

File permissions    
Command Function Syntax/example usage
chmod change permissions for files/directories chmod [OPTIONS] RELATIONS[+/-]PERMISSIONS FILE

ADDITIONAL COMMANDS

ADDITIONAL COMMANDS  
Command Function
du –sh DIR show directory size
whoami display username
date system date/time
cal calendar
find . –name FILE find a file/directory
which CMD display default cmd path
whereis CMD show possible locations of cmd
locate FILE find instances of a file
clear clear screen
sleep 5 pause 5 (any) seconds
top current running processes
ps current running processes
wget URL download specified URL

SHORTCUTS

SHORTCUTS  
Command Function
TAB autocomplete names
UP/DOWN browse previous commands
ctrl+c interrupt/kill anything
ctrl+l clear screen
ctrl+d quit, exit
ctrl+z suspend (use fg to restore)
!! repeat last command
alt+. last argument of previous cmd
ctrl+insert copy selection
shift+insert paste copied text
ctrl+a go to start of the line
ctrl+e go to end of the line
ctrl+r reverse search history
cd ~ go to home

NANO SHORTCUTS

NANO SHORTCUTS  
Command Function
ctrl+r read/insert file
ctrl+o save file
ctrl+x close file
alt+a start selecting text
ctrl+k cut selection
ctrl+u uncut (paste) selection
alt+/ go to end of the file
ctrl+a go to start of the line
ctrl+e go to end of the line
ctrl+c show line number
ctrl+_ go to line number
ctrl+w find matching word
alt+w find next match
ctrl+\ find and replace

PIPES, REDIRECTS

PIPES, REDIRECTS  
Command Function
cmd < file use file as input
cmd > file write output to file
cmd >> file append output to file
cmd 2> stderr error output to file
cmd 1>&2 file send output and error to file
cmd1 \| cmd2 send output of cmd1 to cmd2

PRE-DECLARED VARIABLES

PRE-DECLARED VARIABLES  
Variables* Description
$USER username
$HOME home path
$PWD working directory path
$PATH path for executables
$HOSTNAME machine name
$SHELL current shell
$SSH_CLIENT local client’s IP address
$TERM type of terminal
  • env command lists all the assigned variables

HPC-CLUSTER Commands for SLURM

HPC-CLUSTER Commands   TORQUE
Command Function Syntax/example usage
sinfo -a list all queues sinfo -a
squeue list all jobs squeue
squeue -u userid list jobs for userid squeue -u userid
squeue -t R list running jobs squeue -t R
smap show jobs, partitions and nodes in a graphical network topology smap
sbatch submit a slurm job sbatch [script]
scancel delete slurm batch job scancel [job_id]
scontrol hold hold slurm batch jobs scontrol hold [job_id]
scontrol release release hold on slurm batch jobs scontrol release [job_id]

HPC-CLUSTER Commands for TORQUE

HPC-CLUSTER Commands   TORQUE
Command Function Syntax/example usage
squeue show state of jobs squeue –a # current jobs on cluster
squeue –u username   # current jobs by the user
squeue –j jobid   # information about the job (id#)
squeue -l –u username   # current jobs by the user
scancel delete job from the queue scancel jobid
sbatch submit job to the queue sbatch submissionfile.sub
scontrol control jobs scontrol hold jobid jobid # hold the job
    scontrol release jobid jobid # release the job
    scontrol show jobid jobid # info on the job
srun run a job command srun -N 1 -n 16 -t 4:00:00 --pty bash # start a interactive job session
sinfo show state of nodes and partitions sinfo
    sinfo -p tiny # show info on tiny partition
smap show state of jobs, nodes and partitions (colored) smap
module use preinstalled programs module load PROGRAM # loads program for use
    module list # lists all loaded modules
    module avail # lists available modules
    module unload PROGRAM # unloads module

PS: An A-Z Index of the Bash command line for Linux can be found at found Here