Unix et Programmation Shell
janvier
Vous r´ epondrez aux questions en utilisant deux lignes en moyenne.
Q 1. Pr´ eciser l’origine de UNIX ?
Q 2. Qu’est-ce que GNU/linux ?
Q 3. Citer 3 UNIX populaires ?
Q 4. Qu’est que Ubuntu ?
Q 5. Que signifie : CLI ?
Q 6. Qu’est-ce qu’un shell ?
Q 7. D´ ecrire deux m´ ecanismes fondamentaux du syst` eme UNIX.
Q 8. Pr´ eciser les notions de commande in- terne et externe
Q 9. Pr´ eciser 5 variables d’environnement classiques.
Q 10. R´ esultats des commandes e c h o $ ( 1 + 1 )
e c h o $ ( ( 1 + 1 ) )
Q 11. Expliquer en d´ etail
$ o o p s
bash : o o p s : commande i n t r o u v a b l e
Q 12. Proposer une explication
$ c a t $ ( c a t c a t ) c a t
c a t c a t c a t
Q 13. Que fait la commande
$ f i n d ˜ g u e s t −name ” ∗ . p d f ” \
−e x e c l p r {} \ ;
Q 14. Que fait la commande
$ s e d −i ’ s / [ 0 −9 ] ∗ / (NB) / g ’ f o o
Q 15. Que fait la commande
$ s e d − E ’ s / [ 0 −9 ] { 2 } $ / f o o / ’ bar
Q 16. Expliquer
$ g r e p −ch b i z a r r e . b∗h ∗h∗
0
$ h i s t o r y − w
$ g r e p −ch b i z a r r e . b∗h ∗h∗
1
Q 17. R´ esultat de la commande
$ e c h o { 1 . . 5 } | wc −c
Q 18. Que fait la commande
$ g r e p −r − E ’ [ a−z ] + ’ \
−−i n c l u d e =∗. t e x /tm
Q 19. Expliquer
$ ps −e o p p id , pid , cmd | g r e p $$
26121 12505 bash
12505 12884 ps −e o p p id , pid , cmd 12505 12885 g r e p 12505
Q 20. Expliquer
$ m k f i f o /tmp/ f i f o
$ t r w o r l d h e l l o
</tmp/ f i f o
$ e c h o h e l l o w o r l d
>/tmp/ f i f o h e l l e h e l l o
1
cmd=$1 d s t=$2
f l a g s=read , w r i t e , dup , dup2 , e x e c v e
s t r a c e −f −e t r a c e=$ f l a g s bash −c ”$cmd” &
>$2Q 21. Le script ci-dessus a ´ et´ e utilis´ e pour obtenir la trace ci-dessous.
– Quelle commande a probablement ´ et´ e trac´ ee ? – Commenter les lignes 1–5.
– Commenter les lignes 7–15.
– Commenter les lignes 16–17.
1 open ( ” / e t c / l d . s o . c a c h e ” , O RDONLY) = 3
2 c l o s e ( 3 ) = 0
3 open ( ” / l i b 6 4 / l i b t i n f o . s o . 5 ” , O RDONLY) = 3 4 r e a d ( 3 , ”\177ELF\2\1\1\0\0\0 ” . . . , 8 3 2 ) = 832
5 c l o s e ( 3 ) = 0
6 . . .
7 s t a t ( ” / u s r / l o c a l / b i n / bash ” , 0 x 7 f f f 9 3 7 6 c 8 3 0 ) = −1 8 (No s u c h f i l e o r d i r e c t o r y )
9 s t a t ( ” / u s r / b i n / bash ” , 0 x 7 f f f 9 3 7 6 c 8 3 0 ) = −1 10 (No s u c h f i l e o r d i r e c t o r y )
11 s t a t ( ” / b i n / bash ” , {s t m o d e=S IFREG|0 7 5 5 , s t s i z e =927096 , . . .}) = 0 12 . . .
13 s t a t ( ” / u s r / b i n / c a t ” , 0 x 7 f f f 9 3 7 6 c 7 f 0 ) = −1 14 (No s u c h f i l e o r d i r e c t o r y )
15 s t a t ( ” / b i n / c a t ” , {s t m o d e=S IFREG|0 7 5 5 , s t s i z e =51328 , . . .}) = 0 16 P r o c e s s 13510 a t t a c h e d
17 P r o c e s s 13509 s u s p e n d e d
18 [ p i d 1 3 5 1 0 ] open ( ” / tmp/ d s t ” , O WRONLY|O CREAT|O TRUNC, 0 6 6 6 ) = 3
19 [ p i d 1 3 5 1 0 ] dup2 ( 3 , 1 ) = 1
20 [ p i d 1 3 5 1 0 ] c l o s e ( 3 ) = 0
21 [ p i d 1 3 5 1 0 ] open ( ” / e t c / l d . s o . c a c h e ” , O RDONLY) = 3
22 [ p i d 1 3 5 1 0 ] c l o s e ( 3 ) = 0
23 [ p i d 1 3 5 1 0 ] open ( ” / l i b 6 4 / l i b c . s o . 6 ” , O RDONLY) = 3 24 [ p i d 1 3 5 1 0 ] r e a d ( 3 , ”\177ELF\2 ” . . . , 8 3 2 ) = 832
25 [ p i d 1 3 5 1 0 ] c l o s e ( 3 ) = 0
26 [ p i d 1 3 5 1 0 ] open ( ” / tmp/ s r c ” , O RDONLY) = 3 27 [ p i d 1 3 5 1 0 ] r e a d ( 3 , ” h e l l o\n ” , 3 2 7 6 8 ) = 6 28 [ p i d 1 3 5 1 0 ] w r i t e ( 1 , ” h e l l o\n ” , 6 ) = 6 29 [ p i d 1 3 5 1 0 ] r e a d ( 3 , ” ” , 3 2 7 6 8 ) = 0
30 [ p i d 1 3 5 1 0 ] c l o s e ( 3 ) = 0
31 [ p i d 1 3 5 1 0 ] c l o s e ( 1 ) = 0
32 [ p i d 1 3 5 1 0 ] c l o s e ( 2 ) = 0
33 P r o c e s s 13509 resumed 34 P r o c e s s 13510 d e t a c h e d
35 −−− SIGCHLD ( C h i l d e x i t e d ) @ 0 ( 0 ) −−−