Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
213 views

Linux Tutorial Cheat Sheet

This document provides a cheat sheet for common Linux commands organized into the following categories: cluster commands, task management, browsing files, modifying files, finding files, viewing files, remote management, and useful commands. It summarizes commands for submitting and deleting jobs, listing processes, navigating directories, copying/moving/removing files and folders, searching for files, viewing file contents, connecting to remote machines, and getting command help. The cheat sheet is intended to provide essential Linux commands and their functions in a concise reference guide.

Uploaded by

Hamami InkaZo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
213 views

Linux Tutorial Cheat Sheet

This document provides a cheat sheet for common Linux commands organized into the following categories: cluster commands, task management, browsing files, modifying files, finding files, viewing files, remote management, and useful commands. It summarizes commands for submitting and deleting jobs, listing processes, navigating directories, copying/moving/removing files and folders, searching for files, viewing file contents, connecting to remote machines, and getting command help. The cheat sheet is intended to provide essential Linux commands and their functions in a concise reference guide.

Uploaded by

Hamami InkaZo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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 <s​cri​pt> submit <s​cri​pt> as a job top Constantly updating list of ordered (by resources)
processes
qlogin login to an intera​ctive 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)
<c​omm​and​> running

kill <p​id> terminate process with id <p​id>


Browsing files

cd <d​est​ina​tio​n> change directory


Name Expansions
ls [patt​ern] list all files or match pattern
{a..z} or {1..1​00} 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
$(​<c​omm​and​> ) expands to the result of the command
rm [patt​ern] remove files (-r for recursive)
~ absolute path to home directory
mv [sour​ces] [dest​ina​tion] move / rename file(s) or folder(s)
ls *.txt - list all .txt files
cp [sour​ces] [dest​ina​tion] copy file(s) (-r to create desina​tion)
cp *{0..9} - list files which end in a number between 0 and 9

Modifying direct​ories
Processing stdout
mv [sour​ces] [dest​ina​tion] rename / move directory
awk -F "​," '{print print only column n of files
mkdir <d​ire​cto​ry> create a directory
$<c​olumn number​>}'
rmdir <d​ire​cto​ry> remove a directory
sort (-n) sort alphab​eti​cally (alpha​num​eri​cally)
rm -rf <d​ire​cto​ry> remove directory and all subdir​ect​ories
uniq (-c) print only one instance of repeated lines
(with count of lines)
Finding files
grep (-i) [patt​ern] print lines which contain pattern (ignore
find . -file -name Find all .txt files in the current directory and below case)
"​*.t​xt" and print
wc -l print number of lines
locate [patt​ern] match files with pattern anywhere in the full path sed replace all instances matching
and print /<​pat​ter​n>​/<​rep​lac​emen
​ t>/g <p​att​ern​> with <r​epl​ace​men​t>

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 modifi​cation. cat [files] |

Viewing files
Remote Managment

head [file​names] print first 10 lines of file


​ >​@<h
ssh <u​ser​name ​ os​t> login to multi-user machine
tail [file​names] print last 10 lines of file
scp Cope file(s) from <h​ost​> to
cat [file​names] concat​enate files and print ​ >​@<h
<u​ser​name ​ os​t>​:[r​ emote <l​oca​l> destin​ation.
source] <l​ocal​ >

rsync -t only copy updated files from


<u​ser​nam​e>​@<​hos​t>​:[​remote ​ st​> to <l​ocal​ >
<ho
source] <l​ocal​ >

For the multi-user linux machine, <h​ost​> should be stem-s​su-​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 <f​ile​> give executable priveleges to <f​ile​>

seq <s​tar​t> <st​ep> print sequence of numbers from <s​tar​t> to <s​top​>


<st​op> in increments of <s​tep​>

man <c​omm​and​> open the manual page for man

more <f​ile​> print output in naviga​teable pages

fdisk -l list all the connected drives and partitions

mount <p​art​iti​on> directory will now lead to the partiton (useful for usb
<d​ire​cto​ry> 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

You might also like