Introduction
Navigation
Command
Function
Syntax/example usage
ls
list contents
ls
[OPTIONS] DIRECTORY
pwd
print working directory
pwd
cd
change directory
cd
~ or cd
# enter home directory
cd
.. # go to parent directory
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
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
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
# compress
tar
-czvf
OUTFILE.tar.gz DIRECTORY
# extract
tar
-xzvf
OUTFILE.tar.gz
gzip
gzip files
gzip
SOMEFILE
gunzip
decompress gzipped files
gunzip
SOMEFILE.gz
File permissions
Command
Function
Syntax/example usage
chmod
change permissions for files/directories
chmod
[OPTIONS] RELATIONS[+/-]PERMISSIONS FILE
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
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
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
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
Variable
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
HPC-CLUSTER Commands for SLURM
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]
TUTORIAL SLURM commands
HPC-CLUSTER Commands for TORQUE
Command
Function
Syntax/example usage
squeue
show state of jobs
squeue
–a
# current jobs on a cluster
# current jobs by the user
squeue
–u
username
# information about the job (id#)
squeue
–j
jobid
# current jobs by the user
squeue
-l –u
username
scancel
delete job from the queue
scancel
jobid
sbatch
submit job to the queue
sbatch
submissionfile.sub
scontrol
control jobs
# hold the job
scontrol hold
jobid jobid
# release the job
scontrol release
jobid jobid
# info on the job
scontrol show
jobid jobid
srun
run a job command
srun
-N 1 -n 16 -t 4:00:00 --pty bash
# start an interactive job session
sinfo
show state of nodes and partitions
sinfo
# show info on tiny
partition
sinfo
-p
tiny
smap
show state of jobs, nodes and partitions (colored)
smap
module
use preinstalled programs
# loads program for use
module load
PROGRAM
# lists all loaded modules
module list
# lists available modules
module avail
# unloads module
module unload
PROGRAM
An A-Z Index of the Bash commands for Linux can be found here .