Professional Documents
Culture Documents
L O Go r IR NE G I S T E R
D irec to ry O p eratio n s
pw d Sho w c urrent direc to ry
m k dir dir M ak e direc to ry dir
c d dir C hange direc to ry to dir
c d .. Go up a direc to ry
ls Lis t files
ls O ptio ns
-a Sho w all (inc luding hidden)
-R Rec urs iv e lis t
-r Rev ers e o rder
-t So rt by las t m o dified
-S So rt by file s ize
-l Lo ng lis ting fo rm at
-1 O ne file per line
-m C o m m a- s epa rated o utput
-Q Q uo ted o utput
converted by Web2PDFConvert.com
S earc h F iles
grep pattern files Searc h fo r pattern in files
grep - i C as e ins ens i tiv e s earc h
grep - r Rec urs iv e s earc h
grep - v Inv erted s earc h
grep - o Sho w m atc hed part o f file o nly
find /dir/ - nam e nam e * Find files s tarting w ith nam e in dir
find /dir/ - us er nam e Find files o w ned by nam e in dir
find /dir/ - m m in num Find files m o difed les s than num m inutes ago in dir
w hereis c om m and Find binary / s o urc e / m anual fo r c om m and
lo c ate file Find file (quic k s earc h o f s y s tem index )
F ile O p eratio n s
to uc h file1
C reate file1
c at file1 file2
C o nc ate nate files and o utput
les s file1
V iew and paginate file1
file file1
Get ty pe o f file1
c p file1 file2
C o py file1 to file2
m v file1 file2
M o v e file1 to file2
rm file1
D elete file1
Bas h C om m ands
head file1
unam e - a Sho w s y s tem and k ernel
Sho w firs t 10 lines o f file1
head - n1 /etc /is s ue Sho w dis trib utio n
tail file1
m o unt Sho w m o unted files y s tem s
Sho w las t 10 lines o f file1
date Sho w s y s tem date
uptim e Sho w uptim e tail - F file1
Pro c es s M an ag em en t
ps Sho w s naps ho t o f pro c es s es
to p Sho w real tim e pro c es s es
k ill pid Kill pro c es s w ith id pid
pk ill nam e Kill pro c es s w ith nam e nam e
k illall nam e Kill all pro c es s es w ith nam es beginning nam e
converted by Web2PDFConvert.com
Bas h S h o rtc u ts N an o S h o rtc u ts
C TRL- c Sto p c urrent c o m m and Files
C TRL- z Sleep pro gram C trl- R Read file
C TRL- a Go to s tart o f line C trl- O Sav e file
C TRL- e Go to end o f line C trl- X C lo s e file
C TRL- u C ut fro m s tart o f line C ut and Paste
C TRL- k C ut to end o f line A LT- A Start m ark ing tex t
C TRL- r Searc h his to ry C TRL- K C ut m ark ed tex t o r line
!! Repeat las t c o m m and C TRL- U Pas te tex t
! abc Run las t c o m m and s tarting w ith abc N av igate File
! abc :p Print las t c o m m and s tarting w ith abc A LT- / End o f file
!$ Las t argum ent o f prev io us c o m m and C TRL- A Beginning o f line
A LT- . Las t argum ent o f prev io us c o m m and C TRL- E End o f line
!* A ll argum ents o f prev io us c o m m and C TRL- C Sho w line num ber
^ abc ^ 123 Run prev io us c o m m and, replac ing abc w ith 123 C TRL- _ Go to line num ber
S earc h F ile
Bas h V ariab les
C TRL- W Find
env Sho w env iro n m ent v ariables A LT- W Find nex t
ec ho $N A M E O utput v alue o f $N A M E v ariable C TRL- \ Searc h and replac e
ex po rt N A M E = value Set $N A M E to value
M o re nano info at:
$PA TH Ex ec utable s earc h path http:// w w w .na no - edi to r .o r g/d o c s .php
$H O M E H o m e direc to ry
$SH ELL C urrent s hell S c reen S h o rtc u ts
s c reen
I O R e d i r e c t i o n Start a s c reen s es s io n.
c m d < file s c reen - r
Input o f c m d fro m file Res um e a s c reen s es s io n.
c m d1 < ( c m d2 ) s c reen - lis t
O utput o f c m d2 as file input to c m d1 Sho w y o ur c urrent s c reen s es s io ns .
c m d > file C TRL- A
Standard o utput (s tdo ut) o f c m d to file A c tiv ate c o m m ands fo r s c reen.
c m d > /dev /null C TRL- A c
D is c ard s tdo ut o f c m d C reate a new ins tanc e o f term inal.
c m d > > file C TRL- A n
A ppend s tdo ut to file Go to the nex t ins tanc e o f term inal.
c m d 2> file C TRL- A p
Erro r o utput (s tderr) o f c m d to file Go to the prev io us ins tanc e o f term inal.
c m d 1> & 2 C TRL- A "
s tdo ut to s am e plac e as s tderr Sho w c urrent ins tanc es o f term inals .
c m d 2> & 1 C TRL- A A
s tderr to s am e plac e as s tdo ut Renam e the c urrent ins tanc e.
c m d & > file
M o re s c reen info at:
Ev ery o utput o f c m d to file http:// w w w .gn u.o r g/ s o f tw a re/ s c r een/
c m d refers to a c o m m and.
converted by Web2PDFConvert.com
Pipes F i l e P e r m i s s i o n s
c m d1 | c m d2 c hm o d 775 file
s tdo ut o f c m d1 to c m d2 C hange m o de o f file to 775
c m d1 |& c m d2 c hm o d - R 600 folder
s tderr o f c m d1 to c m d2 Rec urs i v ely c hm o d folder to 600
c ho w n us er : group file
C o m m and Lis ts
C hange file o w ner to us er and gro up to group
c m d1 ; c m d2
Run c m d1 then c m d2 F ile Perm is s io n N u m b ers
c m d1 & & c m d2 Firs t digit is o w ner perm is s io n, s ec o nd is gro up and third is ev ery o ne.
Run c m d2 if c m d1 is s uc c es s ful C alc ulate perm is s io n digits by adding num bers belo w .
c m d1 || c m d2 4 read (r)
Run c m d2 if c m d1 is no t s uc c es s ful 2 w rite (w )
cm d & 1 ex ec ute (x )
converted by Web2PDFConvert.com
2 Pages
P D F (rec o m m ended)
PD F (2 pages )
A ltern ativ e D o w n lo ad s
Cheatographer
D av eC hild
w w w .getpo s tc o o k ie.c o m
converted by Web2PDFConvert.com
Metadata
Languages : Englis h
Lists
LA M P C heat Sheet C o llec tio n by D av eC hild
Favourited By
Comments
gerben , 10:02 28 N o v 11
Thank s fo r c reating this c heat- s heet D av e. The o ne thing I m is s ed w as "grep - o "; Sho w o nly the part o f a m atc hing line that m atc hes PA TTERN
D av eC hild , 10:02 28 N o v 11
a_ s tatham , 10:02 28 N o v 11
The I/O redirec tio n s ec tio n c o uld us e "2> " and "& > " ex am ples , I alw ay s fo rget ho w to redirec t s tderr
D av eC hild , 10:02 28 N o v 11
D av eC hild , 10:02 28 N o v 11
converted by Web2PDFConvert.com
w atts lev i , 19:51 29 N o v 11
H o w are the indented lines added s ev eral o f the c ells lik e Sc reen Sho rtc uts ? RE:
http://gets atis fac tio n.c o m /c heato graphy /to pic s /adding_ a_ tw o _ line_ entry _ in_ a_ lis t
D av eC hild , 08:35 30 N o v 11
A h, Q & A m eans I w o uld be able to c heat w ith it and us e it fo r tw o c o lum n w ith an ex tra line. Thank s fo r the info .
(Reply ing to m y o riginal po s t s eem s unintuitiv e fo r try ing to reply under y o ur po s t, but no t to the o v erall thread... as s um ing this po s t
as I'm think ing it m ight.)
jim , 23:12 30 N o v 11
O n the redirec ts , the o ne I m o s t c o m m o nly us e is igno ring erro rs (2> /dev /null, o r m o re s uc c inc tly 2> & - ).
Fo r ex am ple, if I'm lo o k ing fo r files and I do n't c are that I hav en't ac c es s to parts o f the files y s tem , w e m ight do s o m ething lik e:
Tanner, 10:30 7 M ar 12
ls - h is handy - c hanges s izes to hum an readable fo rm ats . Go es alo ng go o d w ith - S. If I'm us ing it it is generally a ls - alhS
W ane, 07:28 21 M ar 12
I think the "Bas h Sho rtc uts " part is a little m is leading. The "c trl- a", "c trl- e", "c trl- k " is in em ac s m o de. But there s ho uld be m any peo ple
preferring v im - m o de o r s o m e thing lik e that.
D av is Peng, 13:57 22 M ar 12
do w nlo ad PD F is bro k en
converted by Web2PDFConvert.com
C hetan M o rajk ar, 14:35 6 A ug 12
H i,
Thank s
Lo v e y o ur w o rk ....it is s o ....s o helpful! I w o uld lik e to fo rm at a M ic ro D is k us ing Linux C entro s . W hen I lo o k at the Partitio n o n the M ic ro D is k , I
s ee the fo llo w ing c o m m ent....(no n- Linux ). This m ak es s ens e, s inc e I fo rm atted w ith a c o m puter running W in 7! I w ant to us e it o n m y Linux
s y s tem but do no t k no w ho w to do it. I tried fo rm at /dev /s c d1 but no jo y !
Thank y o u
D on
Eric , 08:59 7 A ug 12
I'd jus t lik e to po int o ut a tric k I us e w ith the head and tail c o m m ands :
Firs t, y o u c an des ignate the num ber o f lines to return, lik e s o : head - 100 filenam e
I o ften us e bo th head and tail to gether to get a s ec tio n o f a file by piping the o utput o f o ne into the o ther. The fo llo w ing c o m m and gets 100
lines , s tarting 1000 lines befo re the end o f the file:
tail - 1000 filenam e | head - 100
Yo u c o uld, o f c o urs e, rev ers e the c o m m ands to get a s ec tio n near the to p o f the file. To get lines 91- 100:
head - 100 filenam e | tail - 10
M ark , 08:53 29 A ug 12
I jus t w anted to tak e a m o m ent to thank y o u fo r putting this to gether. This is a big help to m e I am new to O penFiler w itc h I believ e us es bas h at
the c o re s o I am o f c o urs e new to Linux . I didn't really think it w o uld be quite s o diffic ult to find res o urc es that o ne c an us e to nav igate the
c o m m and line but I gues s m o s t fo lk s us e the GU I. But, I'm no t m o s t fo lk s w hen I bo ught m y firs t IBM 8088 I s tarted w ith D O S.A ny w ay , thank s fo r
the tim e and effo rt y o u put into this , s o rry abo ut digres s ing there.
Shrinath, 13:08 4 O c t 12
Ex c ellent Stuff m an.. I think thes e are the m o s t c o m m o nly us ed c o m m ands .. Go o d Effo rt.
JIm m y , 21:43 11 O c t 12
rus s , 16:18 22 O c t 12
C TRL- Z s leeps (s to ps ) the running pro c es s . fg [#] brings it bac k to fo regro und.
to p
C TRL- Z
ps aux | grep to p
converted by Web2PDFConvert.com
fg
H o w ev er, I do n't lik e the "c hm o d" c o m m ands y o u are us ing. I do n't think any bo dy s ho uld us e the num eric v ers io n o f c hm o d any m o re. Yo ur
ex am ple "c hm o d - R 600 fo lder", is the bes t w ay to lo c k y o urs elf o ut o f y o ur o w n fo lder and lo o s e any ex ec utable bits o n the s c ripts . I w o uld
rather us e the s y m bo lic v ers io n:
c hm o d - R o g= u- w fo lder # Giv e o ther and gro up the s am e rights as us er, but rem o v ing w riting rights .
c hm o d u+ s file
c hm o d o + t fo lder
I w o uld als o add the tar c o m m and. N o s y s adm in w o uld s urv iv e w itho ut it.
N ic e o ne...really helpful
Great res o urc e - thank s fo r tak ing the tim e and tro uble to put this o ut there.
M y fav o rite ls o ptio ns are '- ltr' . The t s o rts files by tim e, and r rev ers es that, s o new es t files s ho w up right abo v e the pro m pt, no m atter ho w
lo ng the lis ting is .
converted by Web2PDFConvert.com
dav ey dav e400, 08:43 16 Feb 13
W hat abo ut C TRL+ y to pas te the s tuff y o u c ut bac k in? H o w c an y o u leav e that o ut? C TRL+ a/e and C TRL+ u/y are the pairs I rem em ber.
gy m k a, 08:44 16 Feb 13
M is s ing: s ed
find - ex ec
D arr247, 16:31 5 A pr 13
O r if the PD F at leas t s plit into 2 pages (s o it c o uld be a lam inated 2- s ided s heet) w itho ut c utting c o m m ands in half.
k im c y 929 , 11:09 9 A ug 13
Go o d jo b o n the c heats heet - this w ill definitely c o m e in handy fo r m y Linux ex am nex t w eek . So m e c o m m ands o n um as k w o uld be a go o d
additio n to this c heats heet :).
H i, handy s heet. Jus t o ne thing. Find w ill do a rec urs iv e s earc h by default. In the find /dir - nam e nam e* s ho uld be in do uble quo tes if y o u w ant it
to rec urs iv ely find all files s tarting w ith nam e:
That's bec aus e, w itho ut the quo tes , the s hell w ill ex pand the w ildc ard befo re handing the param eters to find. To unex pec ted things m ight
happen if y o u do n't hav e the quo tes . Pleas e s ee the ex am ples belo w :
$ find .
.
./nam e1
./nam e2
./dir1
./dir1/nam e3
./dir1/nam e1
converted by Web2PDFConvert.com
./dir1/tes t3
./tes t1
$ find . - nam e nam e*
find: paths m us t prec ede ex pres s io n: nam e2
U s age: find [- H ] [- L] [- P] [- O lev el] [- D help|tree|s earc h|s tat|rates |o pt|ex ec ] [path...] [ex pres s io n]
$ find . - nam e "nam e*"
./nam e1
./nam e2
./dir1/nam e3
./dir1/nam e1
$ to uc h dir1/fred1
$ find .
.
./nam e1
./nam e2
./dir1
./dir1/nam e3
./dir1/nam e1
./dir1/tes t3
./dir1/fred1
./tes t1
$ find . - nam e nam e*
find: paths m us t prec ede ex pres s io n: nam e2
U s age: find [- H ] [- L] [- P] [- O lev el] [- D help|tree|s earc h|s tat|rates |o pt|ex ec ] [path...] [ex pres s io n]
$ find . - nam e "nam e*"
./nam e1
./nam e2
./dir1/nam e3
./dir1/nam e1
$ find . - nam e fred*
./dir1/fred1
$ find . - nam e "fred*"
./dir1/fred1
$
grep - B#
This s ho w s w hat y o u are s earc hing plus additio nal lines w here num ber is added. Great fo r D H C P leas e s earc hing.
I w o uld s ugges t to put in s c reen < tty .dev ic e> < baudrate> jus t in c as e any bo dy needs to c o nnec t to s o m e s erial c o ns o le
Great referenc e!
The s ec tio n o n Sc reen is m is s ing "C trl- A d" fo r detac hing.
converted by Web2PDFConvert.com
Kabir, 22:03 10 M ar 14
C o m m and that m ight be us ed to tes t c o nnec tiv ity o f Linux bo x to the Internet, get lo gged o n us er info , and get TC P/IP c o nfiguratio n info . C an
any o ne help m e?
theres als o a go o d o ne here: http://w w w .tec hietek .c o m /2014/04/29/linux - c li- c heat- s heet- w allpaper/
head - n1 /etc /is s ue as a m eans to ac c es s dis tributio n nam e is n't reliable, s inc e the po s t- lo gin s c reen c o uld hav e been c us to m ized.
A m o re reliable v ers io n w o uld be s ed - nr 's /^PRETTY_ N A M E= (.*)/\1/p' /etc /o s - releas e . This s ho uld be true ev en fo r dis tro s us ing legac y init
(i.e., c urrent D ebian, Gento o and ev en Slac k w are).
ls - h? hum an readable?
D F, 08:31 25 A ug 15
w o uld be go o d to add C trl- left/right fo r jum ping argum ents , C trl- ho m e/end fo r jum ping w ho le line.
'ec ho $SH ELL' ac tually prints the default s hell, 'ps - p $$' w ill print the c urrent s hell
Lo v e the c o lo ur, but c o uld it be a s lightly dark er/s tro nger green? It c o m es o ut alm o s t im po s s ible to read o n m y c o lo ur printer. I tried o utputting
in grey s c ale, but the green- o n green s ec tio ns are s till unreadable. N eeds m o re c o ntras t.
A lternativ ely , c hange all the green tex ts to blac k and k eep the bac k gro unds green?
D av eC hild , 16:05 28 M ar 16
converted by Web2PDFConvert.com
Felipe, 19:22 3 A pr 16
Glo O bi , 15:31 4 A pr 16
N atalieM o o re , 05:13 10 A pr 16
H ey Glo O bi, thank s fo r the heads up abo ut the bro k en do w nlo ad butto n o n this c heats heet. W e'll get it fix ed and I'll let y o u k no w w hen
its been do ne. H av e a great day .
N atalieM o o re , 06:49 13 A pr 16
H i Glo O bi,
N at
d.falk o v s k y , 19:54 7 A pr 16
N atalieM o o re , 05:07 10 A pr 16
Thank s d.falk o v s k y , I w ill let D av e k no w the do w nlo ad butto n o n this c heat s heet needs to be fix ed. I w ill let y o u k no w o nc e he has
fix ed it :). So rry fo r the inc o nv enienc e.
N atalieM o o re , 06:48 13 A pr 16
H i d.falk o v s k y ,
This is no w fix ed, y o u s ho uld no w be able to do w nlo ad. Pleas e let m e k no w if y o u hav e any m o re pro blem s .
N at
d.falk o v s k y , 13:15 16 A pr 16
Thank y o u, N atalie!
Go o d jo b D av e, Thank y o u :)
converted by Web2PDFConvert.com
Add a Comment
Your Com m ent
Yo ur N am e
Yo ur Em ail A ddres s
Yo ur C o m m ent
m o d _ r e w r it e C h e a t S h e e t
S u b v e r s io n C h e a t S h e e t
b ash S h o rtc u ts C h e at S h e e t
converted by Web2PDFConvert.com
More Cheat Sheets by DaveChild
R e g u la r E x p r e s s io n s C h e a t S h e e t
C SS2 C he at She e t
m o d _ r e w r it e C h e a t S h e e t
S C E N E S IX - A S t r e e t c a r N a m e d D e s ir e C h e a t S h e e t
converted by Web2PDFConvert.com
R e g u la r E x p r e s s io n s C h e a t S h e e t
S u ic id a l S t u d e n t A s s e s s m e n t C h e a t S h e e t
About Cheatography
C h e a t o g r a p h y is a c o llec tio n o f 3 2 6 0 c h e a t s h e e t s and quic k referenc es in 2 5 l a n g u a g e s fo r ev ery thing fro m g o o g l e to f o o d !
Recent Activity
M ais ie_ publis hed SC EN E SIX - A Streetc ar N am ed D es ire.
22 ho urs 9 m ins ago
hac k ingbeauty replied to : PD F Generatio n fo r 2 C o lum n Bro k e.
1 day 13 ho urs ago
D av idpo l publis hed C o m m o n Res um e M is tak es .
2 day s 12 ho urs ago
D av eC hild
Spac eD uc k
C heato graphy
converted by Web2PDFConvert.com
Share Cheatography!
2.6K
converted by Web2PDFConvert.com