Table des matières

Dernière mise-à-jour : 2020/01/30 03:27

la commande type la commande find /etc/updated

104.7 - Rechercher des fichiers système et les placer dans les bons endroits (2/60)

Le système de fichiers de Linux est organisé autour d'une arborescence unique ayant un point de départ appelé la racine, représenté par le caractère /. En dessous de cette racine se trouvent des répertoires contenant fichiers et sous-répertoires. L'organisation des répertoires est conforme à un standard, appelé le Linux File Hierarchy System.

Linux File Hierarchy System

Debian 6

trainee@debian6:/$ ls -l
total 92
drwxr-xr-x   2 root root  4096  6 déc.   2014 bin
drwxr-xr-x   3 root root  4096  6 déc.   2014 boot
drwxr-xr-x  15 root root  3120 25 août  16:51 dev
drwxr-xr-x 121 root root 12288  4 juil. 15:05 etc
drwxr-xr-x   3 root root  4096 24 avril  2011 home
lrwxrwxrwx   1 root root    28 24 avril  2011 initrd.img -> boot/initrd.img-2.6.32-5-686
drwxr-xr-x  12 root root 12288  6 déc.   2014 lib
drwx------   2 root root 16384 24 avril  2011 lost+found
drwxr-xr-x   3 root root  4096 24 avril  2011 media
drwxr-xr-x   2 root root  4096 14 déc.   2010 mnt
drwxr-xr-x   4 root root  4096  4 déc.   2011 opt
dr-xr-xr-x 128 root root     0  4 juil. 14:34 proc
drwx------  11 root root  4096  7 déc.   2014 root
drwxr-xr-x   2 root root  4096  6 déc.   2014 sbin
drwxr-xr-x   2 root root  4096 21 juil.  2010 selinux
drwxr-xr-x   2 root root  4096 24 avril  2011 srv
drwxr-xr-x  12 root root     0  4 juil. 14:34 sys
drwxrwxrwt  10 root root  4096 25 août  16:34 tmp
drwxr-xr-x  10 root root  4096 24 avril  2011 usr
drwxr-xr-x  14 root root  4096 24 avril  2011 var
lrwxrwxrwx   1 root root    25 24 avril  2011 vmlinuz -> boot/vmlinuz-2.6.32-5-686

Debian 7

trainee@debian7:/$ ls -l
total 84
drwxr-xr-x   2 root root  4096 juin  26 16:06 bin
drwxr-xr-x   3 root root  4096 juin  26 16:09 boot
drwxr-xr-x  14 root root  3160 juil.  4 16:36 dev
drwxr-xr-x 133 root root 12288 juil.  4 16:36 etc
drwxr-xr-x   3 root root  4096 juin  26 15:42 home
lrwxrwxrwx   1 root root    32 juin  26 15:35 initrd.img -> /boot/initrd.img-3.2.0-4-686-pae
lrwxrwxrwx   1 root root    28 juin  26 15:35 initrd.img.old -> /boot/initrd.img-3.2.0-4-486
drwxr-xr-x  15 root root  4096 juin  26 16:01 lib
drwx------   2 root root 16384 juin  26 15:35 lost+found
drwxr-xr-x   3 root root  4096 juil. 15  2014 media
drwxr-xr-x   2 root root  4096 juil.  7  2014 mnt
drwxr-xr-x   2 root root  4096 juil. 15  2014 opt
dr-xr-xr-x 131 root root     0 juin  26 16:17 proc
drwx------   4 root root  4096 juil.  4 15:14 root
drwxr-xr-x  20 root root   880 juil.  4 16:36 run
drwxr-xr-x   2 root root  4096 juin  26 16:07 sbin
drwxr-xr-x   2 root root  4096 juin  10  2012 selinux
drwxr-xr-x   2 root root  4096 juil. 15  2014 srv
drwxr-xr-x  13 root root     0 juin  26 16:17 sys
drwxrwxrwt   9 root root  4096 juil.  4 16:17 tmp
drwxr-xr-x  10 root root  4096 juin  26 15:39 usr
drwxr-xr-x  12 root root  4096 juin  26 15:39 var
lrwxrwxrwx   1 root root    28 juin  26 15:39 vmlinuz -> boot/vmlinuz-3.2.0-4-686-pae
lrwxrwxrwx   1 root root    24 juin  26 15:39 vmlinuz.old -> boot/vmlinuz-3.2.0-4-486

Debian 8

trainee@debian8:/$ ls -l
total 84
drwxr-xr-x   2 root root  4096 juin  28 16:31 bin
drwxr-xr-x   3 root root  4096 juin  28 16:31 boot
drwxr-xr-x  17 root root  3080 juil. 23 17:04 dev
drwxr-xr-x 125 root root 12288 août  27 12:18 etc
drwxr-xr-x   3 root root  4096 juin  28 16:30 home
lrwxrwxrwx   1 root root    33 juin  28 16:26 initrd.img -> /boot/initrd.img-3.16.0-4-686-pae
lrwxrwxrwx   1 root root    29 juin  28 16:26 initrd.img.old -> /boot/initrd.img-3.16.0-4-586
drwxr-xr-x  18 root root  4096 juin  28 16:31 lib
drwxr-xr-x   2 root root  4096 juin   6 17:07 live-build
drwx------   2 root root 16384 juin  28 16:26 lost+found
drwxr-xr-x   3 root root  4096 juin   6 16:32 media
drwxr-xr-x   2 root root  4096 juin   6 16:32 mnt
drwxr-xr-x   3 root root  4096 juin  28 16:38 opt
dr-xr-xr-x 138 root root     0 juin  28 16:41 proc
drwx------   2 root root  4096 juin  28 16:35 root
drwxr-xr-x  24 root root   820 août  27 12:18 run
drwxr-xr-x   2 root root  4096 juin  28 16:39 sbin
drwxr-xr-x   2 root root  4096 juin   6 16:32 srv
dr-xr-xr-x  13 root root     0 juin  28 16:41 sys
drwxrwxrwt  12 root root  4096 juil. 23 16:17 tmp
drwxr-xr-x  10 root root  4096 juin  28 16:29 usr
drwxr-xr-x  11 root root  4096 juin  28 16:29 var
lrwxrwxrwx   1 root root    29 juin  28 16:29 vmlinuz -> boot/vmlinuz-3.16.0-4-686-pae
lrwxrwxrwx   1 root root    25 juin  28 16:29 vmlinuz.old -> boot/vmlinuz-3.16.0-4-586

La commande find

Cette commande sert à rechercher un ou des fichiers dans le répertoire courant ou le répertoire spécifié en argument :

trainee@debian8:~$ find acc
find: `acc': No such file or directory
trainee@debian8:~$ find aac
aac

Important : Notez que si le fichier n'existe pas le système vous en informe clairement. Notez aussi que ce fichier existe le système vous en informe en vous indiquant son nom.

Options de la commande

A faire : Utilisez l'option –help de la commande find pour visualiser les options de la commande.

La commande su

La commande su permet d'assumer l'identité d'un autre utilisateur du système à condition de connaître son mot de passe. Exécutée sans argument, le système suppose que vous souhaitez devenir root :

trainee@debian8:~$ su -
Password: fenestros

Important : Notez que le mot de passe saisi ne sera PAS visible.

Options de la commande

A faire : Utilisez l'option –help de la commande su pour visualiser les options de la commande.

Les commandes locate et updatedb

La commande locate sert à rechercher un ou des fichiers dans l'ensemble du système de fichiers en commençant à la racine (/) en spécifiant une chaîne à rechercher en argumant à la commande. La commande locate utilise une base de données afin d'effectuer sa recherche. Pour construire ou mettre à jour cette base de données avant l'utilisation de la commande pour une recherche, il faut utiliser la commande updatedb en tant que root.

La base de données par défaut est /var/lib/mlocate/mlocate.db :

root@debian8:~# ls -l /var/lib/mlocate/mlocate.db 
-rw-r----- 1 root mlocate 2067895 Aug 19 07:35 /var/lib/mlocate/mlocate.db

Important : Pour plus d'information concernant le format de la base de données, consultez man 5 locatedb.

La commande updatedb peut être configurée en éditant son fichier de configuration /etc/updatedb.conf :

root@debian8:~# cat /etc/updatedb.conf
PRUNE_BIND_MOUNTS="yes"
# PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /media"
PRUNEFS="NFS nfs nfs4 rpc_pipefs afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre tmpfs usbfs udf fuse.glusterfs fuse.sshfs curlftpfs"

L'utilisation des deux commandes est illustrée ci-après :

root@debian8:~# updatedb
root@debian8:~# locate aac
/home/trainee/aac
/lib/modules/3.16.0-4-amd64/kernel/drivers/scsi/aacraid
/lib/modules/3.16.0-4-amd64/kernel/drivers/scsi/aacraid/aacraid.ko
/usr/lib/x86_64-linux-gnu/libaacs.so.0
/usr/lib/x86_64-linux-gnu/libaacs.so.0.4.1
/usr/share/doc/libaacs0
/usr/share/doc/libaacs0/KEYDB.cfg.gz
/usr/share/doc/libaacs0/changelog.Debian.amd64.gz
/usr/share/doc/libaacs0/changelog.Debian.gz
/usr/share/doc/libaacs0/changelog.gz
/usr/share/doc/libaacs0/copyright
/usr/share/mime/audio/aac.xml
/var/cache/apt/archives/libaacs0_0.7.1-1+b1_amd64.deb
/var/lib/dpkg/info/libaacs0:amd64.list
/var/lib/dpkg/info/libaacs0:amd64.md5sums
/var/lib/dpkg/info/libaacs0:amd64.postinst
/var/lib/dpkg/info/libaacs0:amd64.postrm
/var/lib/dpkg/info/libaacs0:amd64.shlibs

Options des commandes

A faire : Utilisez l'option –help des commandes updatedb et locate pour visualiser les options des commandes.

La commande whereis

La commande whereis permet une recherche de l'emplacement des exécutables, des fichiers de configuration et des manuels pour la commande passée en argument :

root@debian8:~# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1ssl.gz /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

Options de la commande

A faire : Utilisez l'option –help de la commande whereis pour visualiser les options de la commande.

La commande which

La commande which permet une recherche de l'emplacement d'un exécutable dans le PATH de l'utilisateur courant et retourne le premier qui est trouvé :

root@debian8:~# which passwd
/usr/bin/passwd

Options de la commande

A faire : Utilisez l'option –help de la commande which pour visualiser les options de la commande.


<html>

Copyright © 2004-2017 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”><img alt=“Licence Creative Commons” style=“border-width:0” src=“http://i.creativecommons.org/l/by-nc-nd/3.0/fr/88x31.png” /></a><br />Ce(tte) oeuvre est mise à disposition selon les termes de la <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”>Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Pas de Modification 3.0 France</a>.

</html>