Linux Tutorial Cheat Sheet
by jkeelan via cheatography.com/55689/cs/14807/
Cluster commands Task management
qstat print list of all your jobs ps See all of your active processes
qsub <script> submit <script> as a job top Constantly updating list of ordered (by resources)
processes
qlogin login to an interactive session on the cluster
time print time taken to complete after command finishes
qdel <job ids> delete the jobs (<job ids> can be a pattern)
<command> running
kill <pid> terminate process with id <pid>
Browsing files
cd <destination> change directory
Name Expansions
ls [pattern] list all files or match pattern
{a..z} or {1..100} expands to the series e.g a b c d ...
pwd print current directory
* expands to match anything, any number of times
You can return to your home directory by using cd ~
? Match anything once
$((2 + 2)) Arithmetic expansion (evaluates to 2)
Modifying files
$(<command> ) expands to the result of the command
rm [pattern] remove files (-r for recursive)
~ absolute path to home directory
mv [sources] [destination] move / rename file(s) or folder(s)
ls *.txt - list all .txt files
cp [sources] [destination] copy file(s) (-r to create desination)
cp *{0..9} - list files which end in a number between 0 and 9
Modifying directories
Processing stdout
mv [sources] [destination] rename / move directory
awk -F "," '{print print only column n of files
mkdir <directory> create a directory
$<column number>}'
rmdir <directory> remove a directory
sort (-n) sort alphabetically (alphanumerically)
rm -rf <directory> remove directory and all subdirectories
uniq (-c) print only one instance of repeated lines
(with count of lines)
Finding files
grep (-i) [pattern] print lines which contain pattern (ignore
find . -file -name Find all .txt files in the current directory and below case)
"*.txt" and print
wc -l print number of lines
locate [pattern] match files with pattern anywhere in the full path sed replace all instances matching
and print /<pattern>/<replacemen
t>/g <pattern> with <replacement>
Can combine with | grep. locate may require sudo updatedb from time to To use on a collection of files, all commands would be prefixed by:
time, and won't work on cluster without some modification. cat [files] |
Viewing files
Remote Managment
head [filenames] print first 10 lines of file
>@<h
ssh <username ost> login to multi-user machine
tail [filenames] print last 10 lines of file
scp Cope file(s) from <host> to
cat [filenames] concatenate files and print >@<h
<username ost>:[r emote <local> destination.
source] <local >
rsync -t only copy updated files from
<username>@<host>:[remote st> to <local >
<ho
source] <local >
For the multi-user linux machine, <host> should be stem-ssu-linux
By jkeelan Published 20th February, 2018. Sponsored by Readability-Score.com
cheatography.com/jkeelan/ Last updated 20th February, 2018. Measure your website readability!
Page 1 of 2. https://readability-score.com
Linux Tutorial Cheat Sheet
by jkeelan via cheatography.com/55689/cs/14807/
Useful
chmod +x <file> give executable priveleges to <file>
seq <start> <step> print sequence of numbers from <start> to <stop>
<stop> in increments of <step>
man <command> open the manual page for man
more <file> print output in navigateable pages
fdisk -l list all the connected drives and partitions
mount <partition> directory will now lead to the partiton (useful for usb
<directory> storage)
stdout can be piped into more to make long outputs readable.
By jkeelan Published 20th February, 2018. Sponsored by Readability-Score.com
cheatography.com/jkeelan/ Last updated 20th February, 2018. Measure your website readability!
Page 2 of 2. https://readability-score.com