Documente Academic
Documente Profesional
Documente Cultură
Cheatsheet
Comand Descrierescurt
s u p s t o p | k i l l f g & b g
p s t r e e ierarhiadeprocese
pipe trimiteunsemnalunuiprocesidentificatprinPID
p k i l l cautunprocesdupnumeiitransmiteunsemnal
treceunprocesnforeground lanseazunprocesnbackgroundrunning treceunprocesdinbackgrounddinstoppednrunning
m k f i f o creazunpipecunume n o h u p ruleazocomandcevaignorasemnalulSIGHUP
Suportlaborator
5.Procese[http://books.google.com/books?id=_JFGzyRxQGcC&pg=PA111]
Arhivlaborator
lab05.tar.gz[http://ocw.cs.pub.ro/courses/_media/uso/laboratoare/lab05.tar.gz]
Introducere
Vizualizareaproceselordinsistem
Pentruaafiainformaiidespreproceseleactive,putemutilizap s .Frniciunargument,listeazproceseledeschisedinterminalulcurent.Apardoardouprocese:shellulb a s h i procesulp s :
s t u d e n t @ u s o : ~ $p s P I DT T Y T I M EC M D 3 8 2 1p t s / 1 0 0 : 0 0 : 0 0b a s h 3 8 7 7p t s / 1 0 0 : 0 0 : 0 0p s
Dacadugmargumentelee f comenziianterioaresevorafiatoateproceseleceruleaznsistem:
s t u d e n t @ u s o : ~ $p se f U I D P I D P P I D CS T I M ET T Y r o o t 1 0 01 9 : 3 7? r o o t 2 0 01 9 : 3 7? r o o t 3 2 01 9 : 3 7? r o o t 6 2 01 9 : 3 7? r o o t 7 2 01 9 : 3 7? r o o t 8 2 01 9 : 3 7? r o o t 1 0 2 01 9 : 3 7? r o o t 1 2 2 01 9 : 3 7? r o o t 1 3 2 01 9 : 3 7? r o o t 1 4 2 01 9 : 3 7? r o o t 1 5 2 01 9 : 3 7? r o o t 1 6 2 01 9 : 3 7? r o o t 1 8 2 01 9 : 3 7? [ . . . ] T I M EC M D 0 0 : 0 0 : 0 0/ s b i n / i n i t 0 0 : 0 0 : 0 0[ k t h r e a d d ] 0 0 : 0 0 : 0 0[ k s o f t i r q d / 0 ] 0 0 : 0 0 : 0 0[ m i g r a t i o n / 0 ] 0 0 : 0 0 : 0 0[ w a t c h d o g / 0 ] 0 0 : 0 0 : 0 0[ m i g r a t i o n / 1 ] 0 0 : 0 0 : 0 0[ k s o f t i r q d / 1 ] 0 0 : 0 0 : 0 0[ w a t c h d o g / 1 ] 0 0 : 0 0 : 0 0[ c p u s e t ] 0 0 : 0 0 : 0 0[ k h e l p e r ] 0 0 : 0 0 : 0 0[ k d e v t m p f s ] 0 0 : 0 0 : 0 0[ n e t n s ] 0 0 : 0 0 : 0 0[ s y n c _ s u p e r s ]
Consultndman,observm:
e f S e l e c ta l lp r o c e s s e s .I d e n t i c a lt oA . D of u l l f o r m a tl i s t i n g .
Putemfolosim a n
p s mpreuncuopiuneadecutarepentruagsidescriereacmpurilorafiate:
u i d U I D s e ee u i d .( a l i a se u i d ) . e u i d E U I D e f f e c t i v eu s e rI D( a l i a su i d ) . p i d P I D p r o c e s sI Dn u m b e ro ft h ep r o c e s s . p p i d P P I D p a r e n tp r o c e s sI D . c C p r o c e s s o ru t i l i z a t i o n .C u r r e n t l y ,t h i si st h ei n t e g e rv a l u eo ft h ep e r c e n tu s a g eo v e rt h el i f e t i m eo ft h ep r o c e s s . s t a r t _ t i m eS T A R T s t a r t i n gt i m eo rd a t eo ft h ep r o c e s s . t n a m e T T Y c o n t r o l l i n gt t y( t e r m i n a l ) . t i m e T I M E c u m u l a t i v eC P Ut i m e ," [ D D ] H H : M M : S S "f o r m a t . u c m d C M D s e ec o m m . c o m m C O M M A N Dc o m m a n dn a m e( o n l yt h ee x e c u t a b l en a m e ) .
r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t r o o t
3 6 7 8 1 0 1 2 1 3 1 4 1 5 1 6 1 8 1 9 2 0 2 1 2 2
0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0
0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0 0 . 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0? 0? 0? 0? 0? 0? 0? 0? 0? 0? 0? 0? 0? 0? 0?
1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7 1 9 : 3 7
0 : 0 0[ k s o f t i r q d / 0 ] 0 : 0 0[ m i g r a t i o n / 0 ] 0 : 0 0[ w a t c h d o g / 0 ] 0 : 0 0[ m i g r a t i o n / 1 ] 0 : 0 0[ k s o f t i r q d / 1 ] 0 : 0 0[ w a t c h d o g / 1 ] 0 : 0 0[ c p u s e t ] 0 : 0 0[ k h e l p e r ] 0 : 0 0[ k d e v t m p f s ] 0 : 0 0[ n e t n s ] 0 : 0 0[ s y n c _ s u p e r s ] 0 : 0 0[ b d i d e f a u l t ] 0 : 0 0[ k i n t e g r i t y d ] 0 : 0 0[ k b l o c k d ] 0 : 0 0[ a t a _ s f f ]
l ) a u x )
Putemvedeasemnificaiaargumentelormaidesfolositepentrup s ,ntoatecele3formate,rulnd
p sh e l p
sauocomandcuunargumentnevalid.
s t u d e n t @ u s o : ~ $p sh e l p * * * * * * * * *s i m p l es e l e c t i o n* * * * * * * * * * * * * * * * * *s e l e c t i o nb yl i s t* * * * * * * * * Aa l lp r o c e s s e s Cb yc o m m a n dn a m e Nn e g a t es e l e c t i o n Gb yr e a lg r o u pI D( s u p p o r t sn a m e s ) aa l lw /t t ye x c e p ts e s s i o nl e a d e r s Ub yr e a lu s e rI D( s u p p o r t sn a m e s ) da l le x c e p ts e s s i o nl e a d e r s gb ys e s s i o nO Rb ye f f e c t i v eg r o u pn a m e ea l lp r o c e s s e s pb yp r o c e s sI D T a l lp r o c e s s e so nt h i st e r m i n a l sp r o c e s s e si nt h es e s s i o n sg i v e n a a l lw /t t y ,i n c l u d i n go t h e ru s e r s tb yt t y g O B S O L E T E-D ON O TU S E ub ye f f e c t i v eu s e rI D( s u p p o r t sn a m e s ) r o n l yr u n n i n gp r o c e s s e s U p r o c e s s e sf o rs p e c i f i e du s e r s x p r o c e s s e sw / oc o n t r o l l i n gt t y s t b yt t y * * * * * * * * * * *o u t p u tf o r m a t* * * * * * * * * * * * * * * * * * * * *l o n go p t i o n s* * * * * * * * * * * o , ou s e r d e f i n e d ff u l l G r o u pU s e rp i dc o l sp p i d j , jj o bc o n t r o l s s i g n a l g r o u pu s e rs i dr o w si n f o O , Op r e l o a d e do v v i r t u a lm e m o r y c u m u l a t i v ef o r m a td e s e l e c t l , ll o n g u u s e r o r i e n t e d s o r tt t yf o r e s tv e r s i o n F e x t r af u l l X r e g i s t e r s h e a d i n gn o h e a d i n gc o n t e x t * * * * * * * * *m i s co p t i o n s* * * * * * * * * V , V s h o wv e r s i o n L l i s tf o r m a tc o d e s f A S C I Ia r tf o r e s t m , m , L , T , H t h r e a d s S c h i l d r e ni ns u m yc h a n g elf o r m a t M , Z s e c u r i t yd a t a c t r u ec o m m a n dn a m e cs c h e d u l i n gc l a s s w , w w i d eo u t p u t n n u m e r i cW C H A N , U I D Hp r o c e s sh i e r a r c h y
Alternativputemrulai
s t u d e n t @ u s o : ~ $p sUs t u d e n t P I DT T Y S T A T T I M EC O M M A N D 2 0 3 8? S s 0 : 0 0/ b i n / s h/ u s r / b i n / x s e s s i o n m a n a g e r 2 0 8 6? S s 0 : 0 0/ u s r / b i n / s s h a g e n t/ u s r / b i n / d b u s l a u n c he x i t w i t h s e s s i o nx s e s s i o n m a n a g e r 2 0 8 9? S 0 : 0 0/ u s r / b i n / d b u s l a u n c he x i t w i t h s e s s i o nx s e s s i o n m a n a g e r 2 0 9 0? S s 0 : 0 1/ / b i n / d b u s d a e m o nf o r kp r i n t p i d5p r i n t a d d r e s s7s e s s i o n 2 1 5 4? S 0 : 0 0/ u s r / l i b / k d e 4 / l i b e x e c / s t a r t _ k d e i n i t+ k c m i n i t _ s t a r t u p 2 1 5 5? S s 0 : 0 0k d e i n i t 4 :k d e i n i t 4R u n n i n g . . . 2 1 5 6? S 0 : 0 0k d e i n i t 4 :k l a u n c h e r[ k d e i n i t ]f d = 9 2 1 5 8? S l 0 : 0 4k d e i n i t 4 :k d e d 4[ k d e i n i t ] 2 1 6 3? S 0 : 0 0/ u s r / b i n / b l u e d e v i l h e l p e r 2 1 6 5? S 0 : 0 0/ u s r / b i n / o b e x d a t a s e r v e rn o d a e m o n 2 3 3 7? S 0 : 0 0/ u s r / b i n / b l u e d e v i l m o n o l i t h i c 2 3 3 9? S 0 : 0 0/ u s r / b i n / k g l o b a l a c c e l 2 3 4 1? S l 0 : 0 0/ u s r / b i n / k w a l l e t d 2 3 4 4? S 0 : 0 0/ u s r / b i n / k a c t i v i t y m a n a g e r d
Serecomandfolosireaargumentelorcu(nstilGNU).Cutoateacestea,nunelecazuriformaBSDestemaipotrivit.
Pipeurianonime
Caracterul| (pipe)estefolositpentruanlnui2comenzi,legndieireastandardaprimeicomenzilaintrareastandardaceleilalte,aacumaratifiguraurmtoare:
Foreground&Background
Diagramaurmtoarearatstrilencaresepoateaflaunprocesicumsetrecedintrostarenalta.
procfs
p r o c f s esteunsistemdefiierevirtual,adicdatelenusegsescpeunsuportfizicpermanent(harddisk).FiecarefiieroferinformaiidespresistemiestestocatfizicnRAM. p r o c f s estemontatn/ p r o c .
Informaiidespreunprocesgsimndirectoruldin/ p r o c carearecanumePIDulprocesului.Pescurt,ctevadintreacestea:
Daemon
Undaemonesteuntipdeprocescareruleaznb a c k g r o u n d isedetaeazdeterminaluldecontrol.Unastfeldeprocesnuvaacceptacomenzidelatastatur. Putemcomunicacuundaemonprin: fiieredeconfigurare semnale Deobicei,proceselecaresuntdaemoniaunumeleterminatnd(sshd),darnuesteoregul. Pachetelececonindaemonideobiceiauscripturidecontrol,localizaten/ e t c / i n i t . d / .Acesteasuntfolositepentrupornire/oprireiacceptunargumentdintre: start stop restart
Semnale
Unuldinmecanismeleprincaresepoatecomunicantreprocesesuntsemnalele.Unutilizatorpoatetrimiteunsemnalunuiprocesfolosindcomandak i l l . Pentruavedeatoatesemnalelecaresepottrimiteunuiprocesutilizmk i l l
l .
s t u d e n t @ u s o : ~ $k i l ll 1 )S I G H U P 2 )S I G I N T 3 )S I G Q U I T 4 )S I G I L L 5 )S I G T R A P 6 )S I G A B R T 7 )S I G B U S 8 )S I G F P E 9 )S I G K I L L 1 0 )S I G U S R 1 1 1 )S I G S E G V 1 2 )S I G U S R 2 1 3 )S I G P I P E 1 4 )S I G A L R M 1 5 )S I G T E R M 1 6 )S I G S T K F L T 1 7 )S I G C H L D 1 8 )S I G C O N T 1 9 )S I G S T O P 2 0 )S I G T S T P 2 1 )S I G T T I N 2 2 )S I G T T O U 2 3 )S I G U R G 2 4 )S I G X C P U 2 5 )S I G X F S Z 2 6 )S I G V T A L R M 2 7 )S I G P R O F 2 8 )S I G W I N C H 2 9 )S I G I O 3 0 )S I G P W R 3 1 )S I G S Y S 3 4 )S I G R T M I N 3 5 )S I G R T M I N + 1 3 6 )S I G R T M I N + 2 3 7 )S I G R T M I N + 3 3 8 )S I G R T M I N + 4 3 9 )S I G R T M I N + 5 4 0 )S I G R T M I N + 6 4 1 )S I G R T M I N + 7 4 2 )S I G R T M I N + 8 4 3 )S I G R T M I N + 9 4 4 )S I G R T M I N + 1 04 5 )S I G R T M I N + 1 14 6 )S I G R T M I N + 1 24 7 )S I G R T M I N + 1 3 4 8 )S I G R T M I N + 1 44 9 )S I G R T M I N + 1 55 0 )S I G R T M A X 1 45 1 )S I G R T M A X 1 35 2 )S I G R T M A X 1 2 5 3 )S I G R T M A X 1 15 4 )S I G R T M A X 1 05 5 )S I G R T M A X 9 5 6 )S I G R T M A X 8 5 7 )S I G R T M A X 7 5 8 )S I G R T M A X 6 5 9 )S I G R T M A X 5 6 0 )S I G R T M A X 4 6 1 )S I G R T M A X 3 6 2 )S I G R T M A X 2 6 3 )S I G R T M A X 1 6 4 )S I G R T M A X
Putemtransmiteanumitesemnaleutilizndcombinaiidetaste.Deexemplu:
Exerciii
1.ps
Analizaiproceselecareruleaznsistemfolosindp s . Afiaiproceselecareaufostdeschisedinterminalulcurent. Rezolvare
s t u d e n t @ u s o : ~ $p s
Afiaitoateproceselecareruleaznsistem.Folosiim a n Rezolvare
s t u d e n t @ u s o : ~ $p se f s t u d e n t @ u s o : ~ $p sa u x
p s (sauseciuneaI n t r o d u c e r e )pentruagsiparametriicorespunztori.ncercaisgsiimaimultesoluii.
p s sauh e l p pentruaaflaargumentelecorespunztoare.
2.top
Utilitarulp s poatefifolositpentruafaceopozproceselorsistemuluilaunanumitmomentdetimp.Pentruavizualizainformaiintimpreal,folosimt o p . Rulaicomanda
s t u d e n t @ u s o : ~ $t o p
3.Ierarhiadeprocese
Utilitarulp s t r e e afieazsubformarborescenttoateproceseleexistentenmomentullansriilui.Utiliznd
s t u d e n t @ u s o : ~ $p s t r e e
4.Timpuldeexecuie
Pentruaaflacttimparulatunanumitproces,sepoatefolosicomandat i m e . Rulai
s t u d e n t @ u s o : ~ $t i m es l e e p3
5.Sistemuldefiiereprocfs
Deschideicueditorulv i m unfiiernounumitb e a t l e s .Scrieiweallliveinayellowsubmarinenfisierisalvaifiierul.Nuiesiidinv i m . ntrunaltterminal,folosiip s pentruaidentificaPIDulprocesuluiv i m pornit.Hint:FolosiiargumentulC alutilitaruluip s . Rulaicomandac d
/ p r o c / $ P I D (nlocuii$ P I D cuPIDulgsitanterior).Listaiconinutuldirectoruluincarevaflai.
6.uptime
Rulaicomandau p t i m e .Folosindpaginademanautilitarului,identificaicereprezintceletreinumeredelal o a d
a v e r a g e .
s t u d e n t @ u s o : ~ $m a nu p t i m e [ . . . ] u p t i m e g i v e s a o n el i n ed i s p l a yo ft h ef o l l o w i n gi n f o r m a t i o n . T h ec u r r e n tt i m e ,h o wl o n gt h es y s t e mh a sb e e nr u n n i n g ,h o wm a n yu s e r sa r ec u r r e n t l yl o g g e do n ,a n dt h es y s t e ml o a da v e r a g e s
Faceifiieruluptime_exdinarhivadelaboratorexecutabilirulailastfel:
s t u d e n t @ u s o : ~ / D o w n l o a d s / l a b 0 5 $c h m o d+ xu p t i m e _ e x s t u d e n t @ u s o : ~ / D o w n l o a d s / l a b 0 5 $. / u p t i m e _ e x
7.Pipeurianonime
ndirectorul~ creaiundirectornumit1 9 6 0 s ,inelcreaifiiereleurmtoare:
s t u d e n t @ u s o : ~ / 1 9 6 0 s $t o u c hT i c k e t t o R i d e _ T h e B e a t l e s . t x tY e s t e r d a y _ T h e B e a t l e s . t x tP e n n y L a n e _ T h e B e a t l e s . t x t s t u d e n t @ u s o : ~ / 1 9 6 0 s $t o u c hS a t i s f a c t i o n _ R o l l i n g S t o n e sB r o w n S u g a r _ R o l l i n g S t o n e sW i l d H o r s e s _ R o l l i n g S t o n e sP l a y W i t h F i r e _ R o l l i n g S t o n e s s t u d e n t @ u s o : ~ / 1 9 6 0 s $t o u c hH e y J u d e _ T h e B e a t l e s s t u d e n t @ u s o : ~ / 1 9 6 0 s $t o u c hR a i n y D a y W o m e n _ B o b D y l a n
l .Hint:folosiiredirectri.
Rulaicomanda
s t u d e n t @ u s o : ~ / 1 9 6 0 s $l sl|c a t|c a t|c a t|c a t|c a t|c a t
Ctefiierearfifostnecesaredacnufoloseampipeuri?
8.Semnale
Utilizaik i l l
l pentruavedeatoatesemnalelecaresepottrimiteunuiproces.
Faceiprogramulsignal_testdinarhivadelaboratorexecutabilirulail:
s t u d e n t @ u s o : ~ $c h m o d+ xs i g n a l _ t e s t s t u d e n t @ u s o : ~ $. / s i g n a l _ t e s t
C T R L Z C T R L C C T R L \
Lafinal,pentruaopriprocesuls i g n a l _ t e s t ,rulaicomanda:
s t u d e n t @ u s o : ~ $k i l l9$ ( p i d o fs i g n a l _ t e s t )
Observaicsemnalul9(SIGKILL)nupoatefitratatdenicioaplicaie.
9.xkill
Pentruaforanchidereauneiaplicaiigraficesepoatefolosicomandax k i l l . Dininterfaagraficdeschideig e d i t Deschideiunterminal.Tastaicomandax k i l l . nterminalaaprutmesajul:
S e l e c tt h ew i n d o ww h o s ec l i e n ty o uw i s ht ok i l lw i t hb u t t o n1
Ceformaremouseul? Daiclickundevaninteriorulferestreig e d i t .
10.fg.Operatorul&.
Utilizndv i m ,deschideifiierulT h e B e a t l e s :
v i mT h e B e a t l e s
ScrieitextulJ o h n
L e n n o n nfiier.
11.bg.Variabila$!
Rulaicomanda
s t u d e n t @ u s o : ~ $c a t/ d e v / r a n d o m
$ ! estePIDulultimuluiprocesaflatnbackground.
Rezolvare
s t u d e n t @ u s o : ~ $k i l l9$ !
12.htop
13.less.more
Folosindp s ilistareatuturorproceselor,determinaiPIDulprocesuluig n o m e p a n e l . NUfolosiiscrollsauparametrulC .Folosiil e s s saum o r e pentruaprelucraoutputulp s .Apsaiq pentruaprsil e s s . Observaicl e s s permiteoperaiimaiavansatedectm o r e .Sespunefrecventcl e s s ism o r e Rezolvare
s t u d e n t @ u s o : ~ $p se|l e s s
14.Pipeuricunume
Untipspecialdefiiereunixsuntpipeurilecunume.Acesteaauoreprezentarefizicpedisc. Creaiunpipecunumelet w i t t e r :
s t u d e n t @ u s o : ~ $m k f i f ot w i t t e r
15.FindoutPIDs
Folosiip s ig r e p pentruaaflaPIDulterminaluluicurent. Cesentmpldacaveimaimultesesiunideschise?
$ $ esteovariabildemediuspecialcareconinePIDulprocesuluicurent.
DeterminaiPIDulterminaluluicurent. DeterminaiPIDulprocesuluiprinte.(folosiivariabilademediu$ P P I D ) Aflainumeleprocesuluiprinte.(p s ig r e p ) Rezolvare
s t u d e n t @ u s o : ~ $p se|g r e pb a s h s t u d e n t @ u s o : ~ $e c h o$ $ s t u d e n t @ u s o : ~ $e c h o$ P P I D s t u d e n t @ u s o : ~ $p se|g r e p$ P I D# r e p l a c e$ P I Dc uc e lo b i n u ta n t e r i o r
16.pgrep
Deschideieditorulv i . ntrunaltterminal,folosiicomandap g r e p pentruaafianumeleipidultuturorproceselorv i dinsistem. Cutaiparametrull nm a n
p g r e p ifolosiilpentruacompletalistadePIDuriobinutanteriorcudatedesprenumeleproceselor.
17.Daemon
Rulaiprogramuls i g n a l _ t e s t dinarhivastfel:
s t u d e n t @ u s o : ~ $. / s i g n a l _ t e s t4 2
Programulcreeazundaemon.FolosiiunprocedeupentruaaflaPIDulprocesuluicreat. Rezolvare
s t u d e n t @ u s o : ~ $p g r e ps i g n a l _ t e s t
18.Nohup
Porniiunprocesfolosindcomandap i n g
c1 0 0 0 0g o o g l e . c o m ntrunterminal.
p i n gc1 0 0 0 0g o o g l e . c o m& )
19.disown
Rulaicomandap i n g
Deschideiunaltterminalirulaidinnoup i n g
d i s o w n esteocomandbuiltinashelluluicarefacecaunprocessnuseterminenmomentulncheieriisesiuniicurente.
20.Proceseorfan
Demonstrai,pornindproceseitrimindsemnalelecorespunztoare,cdacterminmprinteleunuiproces,atuncicopiiluisuntpreluaideprocesuli n i t . Hint:porniiunx t e r m dininteriorulaltuix t e r m pornitdinterminaliterminaiprimulx t e r m pornit. Puteifolosip s t r e e pentruvizualizarerapidsaup s afindiP P I D . Rezolvare
0 $x t e r m 1 $x t e r m
Senchideprimulx t e r m pornit.
2 $p se oc m d , p i d , p p i d|g r e px t e r m
21.Screen
Instalaipachetuls c r e e n .Folosiilpentruarula,nparalel,paginademanualaprogramuluis c r e e n ,oinstandev i m iprocesulcorespunztorcomenziip i n g g o o g l e . c o m . Utilizndpaginademanual,determinaicombinaiadetastenecesarpentruaprsis c r e e n fraopriproceselecareruleaz. Pentruaverifica,conectaivlasesiuneaanterioardes c r e e n . Rezolvare ControlAControlCcreeazofereastrnou ControlAnumrnavigheazlafereastranumr ControlAControlDdetaeazscreen Resumelaosesiunesefacecus c r e e n
r
uso/laboratoare/laborator05.txtLastmodified:2012/11/1911:48byioan.eftimie