• Aucun résultat trouvé

CT 2013/1

N/A
N/A
Protected

Academic year: 2022

Partager "CT 2013/1"

Copied!
2
0
0

Texte intégral

(1)

Unix et Programmation Shell

 janvier 

Vous r´epondrez aux questions en utilisant deux lignes en moyenne.

Q 1. Pour les 3 premi`eres sections du manuel : 1 Commandes utilisateur, 2 Appels syst`eme, 3 Fonc- tions de biblioth`eque C, citer un exemple de page.

Q 2. Quel hacker est `a l’origine du projet GNU ? Q 3. Pr´eciser la terminologie : LINUX.

Q 4. Pr´eciser la terminologie : POSIX.

Q 5. Que signifie : CLI ? Q 6. Citer un shell populaire.

Q 7. D´ecrire deux m´ecanismes fondamentaux du syst`eme UNIX.

Q 8. Que permet de faire la fonction Csystem? Q 9. Commenter.

$ c a t v a r . sh c p t=0

( w h i l e [ $ c p t −l t 3 ] ; do e c h o −n $ c p t

l e t c p t++

done ) e c h o $ c p t

$ . / v a r . sh 0120

Q 10. Le binaire run.exe ouvre le fichier run.log en ´ecriture. A priori, qui de drm, ken ou pil peut ex´ecuterrun.exe sans probl`eme ?

−r−−rw−r−− 1 ken go run . l o g

−−−x−−s−−x 1 p i l go run . e x e drwx−−−−−− 1 drm go /home/drm drwx−−−−−− 1 ken yy /home/ ken drwx−−−−−− 1 p i l xx /home/ p i l

Q 11. Proposer une commande plus courte pour r´ealiser le mˆeme travail que :

$ f i n d . −name ’∗’ −e x e c e c h o {} \;

Q 12. Commenter la commande

$ f i n d / −maxdepth 1 −perm +1000

−p r i n t f ”%p−%m−%M\n”

/tmp−1777−drwxrwxrwt

Q 13. Pr´eciser au moins trois variables d’envi- ronnement initialis´ees par login.

Q 14. Que fait la commande :

$ f i n d −name ’∗. html ’ −e x e c \ s e d −i ’ s /USTV/UTLN/g ’ ’{ }’ \; Q 15. Expliquer

$ l s $ ( f i n d . −name ’ l s ’ ) . / l s

Q 16. Expliquer

$ u n a l i a s x

$ x

bash : x : commande i n t r o u v a b l e

$ s o u r c e x

$ x h e l l o

Q 17. Ecrire un script tri.sh pour trier les arguments de la ligne de commande en mode num´erique.

Q 18. Proposer une explication

$ f i n d −name x∗

. / x . l o g

$ t o u c h xxx

$ f i n d −name x∗ 2>/dev / n u l l ;

$ e c h o $ ? 1

Q 19. Quel est le r´esultat de

$ e c h o {1 . . 3} \

| awk −F2 ’{p r i n t $2$1}’

1

(2)

1 e x e c v e ( ” / b i n / bash . . .

2 open ( ” / e t c / l d . s o . c a c h e ” , O RDONLY) = 3

3 open ( ” / dev / t t y ” , O RDWR|O NONBLOCK|O LARGEFILE) = 3 4 open ( ” / p r o c / meminfo ” , O RDONLY) = 3

5 r e a d ( 3 , ”MemTotal : 1025748 kB\nMemF ” . . . , 1 0 2 4 ) = 1024 6 c l o n e ( P r o c e s s 3605 a t t a c h e d

7 [ p i d 3 6 0 4 ] c l o n e ( P r o c e s s 3606 a t t a c h e d

8 [ p i d 3 6 0 6 ] dup2 ( 3 , 0 ) = 0

9 [ p i d 3 6 0 6 ] open ( ” / tmp/ d s t ” , O WRONLY|O CREAT|O TRUNC|O LARGEFILE , 0 6 6 6 )

10 [ p i d 3 6 0 6 ] dup2 ( 3 , 1 ) = 1

11 [ p i d 3 6 0 6 ] e x e c v e ( ” / u s r / b i n /wc ” , [ ” wc ” , ”−l ” ] , [ / 42 v a r s / ] ) = 0

12 [ p i d 3 6 0 5 ] dup2 ( 4 , 1 ) = 1

13 [ p i d 3 6 0 6 ] open ( ” / e t c / l d . s o . c a c h e ” , O RDONLY) = 3

14 [ p i d 3 6 0 5 ] e x e c v e ( ” / b i n / c a t ” , [ ” c a t ” , ”/tmp/ s r c ” ] , [ / 42 v a r s / ] ) = 0 15 [ p i d 3 6 0 5 ] open ( ” / e t c / l d . s o . c a c h e ” , O RDONLY) = 3

16 [ p i d 3 6 0 6 ] <. . . open resumed> ) = 3

17 [ p i d 3 6 0 6 ] r e a d ( 3 , ”# L o c a l e name a l i a s d a t a b a s e .\n # ” . . . , 4 0 9 6 ) = 2512 18 [ p i d 3 6 0 6 ] r e a d ( 3 , ” ” , 4 0 9 6 ) = 0

19 [ p i d 3 6 0 5 ] open ( ” / tmp/ s r c ” , O RDONLY|O LARGEFILE) = 3 20 [ p i d 3 6 0 5 ] r e a d ( 3 , <u n f i n i s h e d . . .>

21 [ p i d 3 6 0 6 ] <. . . open resumed> ) = 3

22 [ p i d 3 6 0 5 ] <. . . r e a d resumed> ” h e l l o w o r l d\n ” , 3 2 7 6 8 ) = 12 23 [ p i d 3 6 0 5 ] w r i t e ( 1 , ” h e l l o w o r l d\n ” , 1 2 ) = 12

24 [ p i d 3 6 0 5 ] r e a d ( 3 , ” ” , 3 2 7 6 8 ) = 0 25 [ p i d 3 6 0 6 ] r e a d ( 0 , ” h e l l o w o r l d\n ” , 1 6 3 8 4 ) = 12 26 [ p i d 3 6 0 6 ] r e a d ( 0 , ” ” , 1 6 3 8 4 ) = 0 27 [ p i d 3 6 0 6 ] w r i t e ( 1 , ”1\n ” , 2 ) = 2

28 −−− {s i s i g n o=SIGCHLD, s i c o d e=CLD EXITED , s i p i d =3605 , s i s t a t u s =0 , s i

Fig. 1 – traces d’une commande.

Q 20. Que fait la commande

$ s e d −i r E ’ s / [ ]+ $ / / ’ f i c h i e r Q 21. Que fait la commande

$ g r e p −vE ’ ˆ $ ’ s r c > d s t Q 22. Que fait la commande

$ g r e p −r l E ’ ( [ 0−9 ] +\. ){3}[ 0−9 ] + ’ \

−−i n c l u d e=r∗.∗f /tmp 2>/dev / n u l l Q 23. Expliquer

$ x=$$ ; w h i l e [ $x != 0 ] ; do ; \ ps −−no−h e a d e r s −p$x −opid , cmd ; \

x=$ ( ps −−no−h e a d e r s −p$x −o p p i d ) ;\ done

2679 / b i n / bash

2678 vim upsh−x−c t−13−1. t e x 2571 bash

2049 gnome−t e r m i n a l 1 / s b i n / i n i t Q 24. Expliquer

$ m k f i f o /tmp/ f i f o

$ t r 123 456 < /tmp/ f i f o &

$ e c h o 1 2 3 4 5 6 > /tmp/ f i f o 4 5 6 4 5 6

Q 25. Le script ci-dessous a ´et´e utilis´e pour obtenir les traces de la figure ( ??).

#!/ b i n / bash

s t r a c e −f f −e t r a c e=open , read , w r i t e , dup2 , c l o n e , e x e c v e \ bash −c ” $∗” |& s e d ’ s / bash .∗/ bash . . . / ’ \

| g r e p −vE ’ ( s h a r e|l i b|s t a c k|ˆ Proc|ELF ) ’ | c u t −c1−72 > t r a c e s . t x t – Combien de processus ont ´et´e lanc´es ?

– Quelle commande a ´et´e trac´ee ?

2

Références

Documents relatifs

[r]

[r]

[r]

un script (ou une fonction) scilab donnant la solution exacte et la solution num´ erique donn´ ee par le sch´ ema

D´ ecrire les polynˆ omes d’interpolation de Hermite dans le cadre g´

Estimer le nombre minimum de points pour que l’erreur entre la fonction et son polynˆ ome d’in- terpolation de Lagrange soit inf´ erieure ` a 0.1, 0.01

Donner une estimation de l’erreur d’int´ egration.. Donner une estimation de l’erreur

La convergence de la formule du point milieu compos´ ee est quadratique.. EXERCICE 3 Formule