Table des matières

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

Gestion des Paramètres du Matériel et les Ressources

Fichiers Spéciaux

Dans l'ordinateur les périphériques sont reliés à un contrôleur qui communique avec le processeur à l'aide d'un bus. Le contrôleur ainsi que les périphériques nécessitent des pilotes. Sous Linux, les pilotes sont généralement fournis sous la forme d'un module. Chaque périphérique est représenté par un fichier spécial dans le répertoire /dev et c'est dans ce fichier que le système trouve les informations nécessaires pour s'adresser au pilote.

Important : Les périphériques qui nécessitent à ce que l'ordinateur soit éteint afin des les brancher/débrancher sont appelés communément Cold Plug Devices. Les périphériques qui peuvent être brancher/débrancher à chaud sont appelés des Hot Plug Devices.

Consultez le contenu du répertoire /dev :

root@ubuntu:/# ls -l /dev
total 0
crw-------  1 root    root     10, 235 oct.  26 12:42 autofs
drwxr-xr-x  2 root    root         640 oct.  26 12:42 block
drwxr-xr-x  2 root    root         100 oct.  26 12:42 bsg
crw-------  1 root    root     10, 234 oct.  26 12:42 btrfs-control
drwxr-xr-x  3 root    root          60 oct.  26 12:42 bus
lrwxrwxrwx  1 root    root           3 oct.  26 12:43 cdrom -> sr0
drwxr-xr-x  2 root    root        3460 oct.  29 15:57 char
crw-------  1 root    root      5,   1 oct.  26 12:43 console
lrwxrwxrwx  1 root    root          11 oct.  26 12:42 core -> /proc/kcore
drwxr-xr-x  2 root    root          60 oct.  26 12:42 cpu
crw-------  1 root    root     10,  60 oct.  26 12:42 cpu_dma_latency
crw-------  1 root    root     10, 203 oct.  26 12:42 cuse
drwxr-xr-x  4 root    root          80 oct.  26 12:42 disk
drwxr-xr-x  2 root    root          60 oct.  26 12:42 dri
crw-------  1 root    root     10,  61 oct.  26 12:42 ecryptfs
lrwxrwxrwx  1 root    root          13 oct.  26 12:42 fd -> /proc/self/fd
crw-rw-rw-  1 root    root      1,   7 oct.  26 12:42 full
crw-rw-rw-  1 root    root     10, 229 oct.  26 12:42 fuse
crw-------  1 root    root    251,   0 oct.  29 15:57 hidraw0
crw-------  1 root    root     10, 228 oct.  26 12:42 hpet
drwxr-xr-x  4 root    root         300 oct.  29 15:57 input
crw-r--r--  1 root    root      1,  11 oct.  26 12:42 kmsg
srw-rw-rw-  1 root    root           0 oct.  26 12:43 log
brw-rw----  1 root    disk      7,   0 oct.  26 12:42 loop0
brw-rw----  1 root    disk      7,   1 oct.  26 12:42 loop1
brw-rw----  1 root    disk      7,   2 oct.  26 12:42 loop2
brw-rw----  1 root    disk      7,   3 oct.  26 12:42 loop3
brw-rw----  1 root    disk      7,   4 oct.  26 12:42 loop4
brw-rw----  1 root    disk      7,   5 oct.  26 12:42 loop5
brw-rw----  1 root    disk      7,   6 oct.  26 12:42 loop6
brw-rw----  1 root    disk      7,   7 oct.  26 12:42 loop7
crw-------  1 root    root     10, 237 oct.  26 12:42 loop-control
drwxr-xr-x  2 root    root          60 oct.  26 12:42 mapper
crw-------  1 root    root     10, 227 oct.  26 12:42 mcelog
crw-r-----  1 root    kmem      1,   1 oct.  26 12:42 mem
drwxr-xr-x  2 root    root          60 oct.  26 12:42 net
crw-------  1 root    root     10,  59 oct.  26 12:42 network_latency
crw-------  1 root    root     10,  58 oct.  26 12:42 network_throughput
crw-rw-rw-  1 root    root      1,   3 oct.  26 12:42 null
crw-r-----  1 root    kmem      1,   4 oct.  26 12:42 port
crw-------  1 root    root    108,   0 oct.  26 12:42 ppp
crw-------  1 root    root     10,   1 oct.  26 12:42 psaux
crw-rw-rw-  1 root    tty       5,   2 oct.  30 10:52 ptmx
drwxr-xr-x  2 root    root           0 oct.  26 12:42 pts
brw-rw----  1 root    disk      1,   0 oct.  26 12:42 ram0
brw-rw----  1 root    disk      1,   1 oct.  26 12:42 ram1
brw-rw----  1 root    disk      1,  10 oct.  26 12:42 ram10
brw-rw----  1 root    disk      1,  11 oct.  26 12:42 ram11
brw-rw----  1 root    disk      1,  12 oct.  26 12:42 ram12
brw-rw----  1 root    disk      1,  13 oct.  26 12:42 ram13
brw-rw----  1 root    disk      1,  14 oct.  26 12:42 ram14
brw-rw----  1 root    disk      1,  15 oct.  26 12:42 ram15
brw-rw----  1 root    disk      1,   2 oct.  26 12:42 ram2
brw-rw----  1 root    disk      1,   3 oct.  26 12:42 ram3
brw-rw----  1 root    disk      1,   4 oct.  26 12:42 ram4
brw-rw----  1 root    disk      1,   5 oct.  26 12:42 ram5
brw-rw----  1 root    disk      1,   6 oct.  26 12:42 ram6
brw-rw----  1 root    disk      1,   7 oct.  26 12:42 ram7
brw-rw----  1 root    disk      1,   8 oct.  26 12:42 ram8
brw-rw----  1 root    disk      1,   9 oct.  26 12:42 ram9
crw-rw-rw-  1 root    root      1,   8 oct.  26 12:42 random
crw-rw-r--+ 1 root    root     10,  62 oct.  26 12:42 rfkill
lrwxrwxrwx  1 root    root           4 oct.  26 12:42 rtc -> rtc0
crw-------  1 root    root    254,   0 oct.  26 12:42 rtc0
brw-rw----  1 root    disk      8,   0 oct.  26 12:43 sda
brw-rw----  1 root    disk      8,   1 oct.  26 12:43 sda1
brw-rw----  1 root    disk      8,   2 oct.  26 12:43 sda2
brw-rw----  1 root    disk      8,   5 oct.  26 12:43 sda5
brw-rw----  1 root    disk      8,  16 oct.  26 12:42 sdb
crw-rw----+ 1 root    cdrom    21,   0 oct.  26 12:42 sg0
crw-rw----  1 root    disk     21,   1 oct.  26 12:42 sg1
crw-rw----  1 root    disk     21,   2 oct.  26 12:42 sg2
lrwxrwxrwx  1 root    root           8 oct.  26 12:42 shm -> /run/shm
crw-------  1 root    root     10, 231 oct.  26 12:42 snapshot
drwxr-xr-x  3 root    root         180 oct.  26 12:43 snd
brw-rw----+ 1 root    cdrom    11,   0 oct.  26 12:43 sr0
lrwxrwxrwx  1 root    root          15 oct.  26 12:42 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root    root          15 oct.  26 12:42 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root    root          15 oct.  26 12:42 stdout -> /proc/self/fd/1
crw-rw-rw-  1 root    tty       5,   0 oct.  30 10:37 tty
crw--w----  1 root    tty       4,   0 oct.  26 12:42 tty0
crw-rw----  1 root    tty       4,   1 oct.  26 12:43 tty1
crw--w----  1 root    tty       4,  10 oct.  26 12:42 tty10
crw--w----  1 root    tty       4,  11 oct.  26 12:42 tty11
crw--w----  1 root    tty       4,  12 oct.  26 12:42 tty12
crw--w----  1 root    tty       4,  13 oct.  26 12:42 tty13
crw--w----  1 root    tty       4,  14 oct.  26 12:42 tty14
crw--w----  1 root    tty       4,  15 oct.  26 12:42 tty15
crw--w----  1 root    tty       4,  16 oct.  26 12:42 tty16
crw--w----  1 root    tty       4,  17 oct.  26 12:42 tty17
crw--w----  1 root    tty       4,  18 oct.  26 12:42 tty18
crw--w----  1 root    tty       4,  19 oct.  26 12:42 tty19
crw-rw----  1 root    tty       4,   2 oct.  26 12:42 tty2
crw--w----  1 root    tty       4,  20 oct.  26 12:42 tty20
crw--w----  1 root    tty       4,  21 oct.  26 12:42 tty21
crw--w----  1 root    tty       4,  22 oct.  26 12:42 tty22
crw--w----  1 root    tty       4,  23 oct.  26 12:42 tty23
crw--w----  1 root    tty       4,  24 oct.  26 12:42 tty24
crw--w----  1 root    tty       4,  25 oct.  26 12:42 tty25
crw--w----  1 root    tty       4,  26 oct.  26 12:42 tty26
crw--w----  1 root    tty       4,  27 oct.  26 12:42 tty27
crw--w----  1 root    tty       4,  28 oct.  26 12:43 tty28
crw--w----  1 root    tty       4,  29 oct.  26 12:42 tty29
crw-rw----  1 root    tty       4,   3 oct.  26 12:43 tty3
crw--w----  1 root    tty       4,  30 oct.  26 12:43 tty30
crw--w----  1 root    tty       4,  31 oct.  26 12:43 tty31
crw--w----  1 root    tty       4,  32 oct.  26 12:43 tty32
crw--w----  1 root    tty       4,  33 oct.  26 12:43 tty33
crw--w----  1 root    tty       4,  34 oct.  26 12:43 tty34
crw--w----  1 root    tty       4,  35 oct.  26 12:43 tty35
crw--w----  1 root    tty       4,  36 oct.  26 12:43 tty36
crw--w----  1 root    tty       4,  37 oct.  26 12:43 tty37
crw--w----  1 root    tty       4,  38 oct.  26 12:43 tty38
crw--w----  1 root    tty       4,  39 oct.  26 12:43 tty39
crw-rw----  1 root    tty       4,   4 oct.  26 12:43 tty4
crw--w----  1 root    tty       4,  40 oct.  26 12:43 tty40
crw--w----  1 root    tty       4,  41 oct.  26 12:43 tty41
crw--w----  1 root    tty       4,  42 oct.  26 12:43 tty42
crw--w----  1 root    tty       4,  43 oct.  26 12:43 tty43
crw--w----  1 root    tty       4,  44 oct.  26 12:43 tty44
crw--w----  1 root    tty       4,  45 oct.  26 12:43 tty45
crw--w----  1 root    tty       4,  46 oct.  26 12:43 tty46
crw--w----  1 root    tty       4,  47 oct.  26 12:43 tty47
crw--w----  1 root    tty       4,  48 oct.  26 12:43 tty48
crw--w----  1 root    tty       4,  49 oct.  26 12:43 tty49
crw-rw----  1 root    tty       4,   5 oct.  26 12:43 tty5
crw--w----  1 root    tty       4,  50 oct.  26 12:43 tty50
crw--w----  1 root    tty       4,  51 oct.  26 12:43 tty51
crw--w----  1 root    tty       4,  52 oct.  26 12:43 tty52
crw--w----  1 root    tty       4,  53 oct.  26 12:43 tty53
crw--w----  1 root    tty       4,  54 oct.  26 12:43 tty54
crw--w----  1 root    tty       4,  55 oct.  26 12:43 tty55
crw--w----  1 root    tty       4,  56 oct.  26 12:43 tty56
crw--w----  1 root    tty       4,  57 oct.  26 12:43 tty57
crw--w----  1 root    tty       4,  58 oct.  26 12:43 tty58
crw--w----  1 root    tty       4,  59 oct.  26 12:43 tty59
crw-rw----  1 root    tty       4,   6 oct.  26 12:43 tty6
crw--w----  1 root    tty       4,  60 oct.  26 12:43 tty60
crw--w----  1 root    tty       4,  61 oct.  26 12:43 tty61
crw--w----  1 root    tty       4,  62 oct.  26 12:43 tty62
crw--w----  1 root    tty       4,  63 oct.  26 12:43 tty63
crw--w----  1 root    tty       4,   7 oct.  26 12:43 tty7
crw--w----  1 root    tty       4,   8 oct.  26 12:43 tty8
crw--w----  1 root    tty       4,   9 oct.  26 12:43 tty9
crw-------  1 root    root      5,   3 oct.  26 12:43 ttyprintk
crw-rw----  1 root    dialout   4,  64 oct.  26 12:42 ttyS0
crw-rw----  1 root    dialout   4,  65 oct.  26 12:42 ttyS1
crw-rw----  1 root    dialout   4,  74 oct.  26 12:42 ttyS10
crw-rw----  1 root    dialout   4,  75 oct.  26 12:42 ttyS11
crw-rw----  1 root    dialout   4,  76 oct.  26 12:42 ttyS12
crw-rw----  1 root    dialout   4,  77 oct.  26 12:42 ttyS13
crw-rw----  1 root    dialout   4,  78 oct.  26 12:42 ttyS14
crw-rw----  1 root    dialout   4,  79 oct.  26 12:42 ttyS15
crw-rw----  1 root    dialout   4,  80 oct.  26 12:42 ttyS16
crw-rw----  1 root    dialout   4,  81 oct.  26 12:42 ttyS17
crw-rw----  1 root    dialout   4,  82 oct.  26 12:42 ttyS18
crw-rw----  1 root    dialout   4,  83 oct.  26 12:42 ttyS19
crw-rw----  1 root    dialout   4,  66 oct.  26 12:42 ttyS2
crw-rw----  1 root    dialout   4,  84 oct.  26 12:42 ttyS20
crw-rw----  1 root    dialout   4,  85 oct.  26 12:42 ttyS21
crw-rw----  1 root    dialout   4,  86 oct.  26 12:42 ttyS22
crw-rw----  1 root    dialout   4,  87 oct.  26 12:42 ttyS23
crw-rw----  1 root    dialout   4,  88 oct.  26 12:42 ttyS24
crw-rw----  1 root    dialout   4,  89 oct.  26 12:42 ttyS25
crw-rw----  1 root    dialout   4,  90 oct.  26 12:42 ttyS26
crw-rw----  1 root    dialout   4,  91 oct.  26 12:42 ttyS27
crw-rw----  1 root    dialout   4,  92 oct.  26 12:42 ttyS28
crw-rw----  1 root    dialout   4,  93 oct.  26 12:42 ttyS29
crw-rw----  1 root    dialout   4,  67 oct.  26 12:42 ttyS3
crw-rw----  1 root    dialout   4,  94 oct.  26 12:42 ttyS30
crw-rw----  1 root    dialout   4,  95 oct.  26 12:42 ttyS31
crw-rw----  1 root    dialout   4,  68 oct.  26 12:42 ttyS4
crw-rw----  1 root    dialout   4,  69 oct.  26 12:42 ttyS5
crw-rw----  1 root    dialout   4,  70 oct.  26 12:42 ttyS6
crw-rw----  1 root    dialout   4,  71 oct.  26 12:42 ttyS7
crw-rw----  1 root    dialout   4,  72 oct.  26 12:42 ttyS8
crw-rw----  1 root    dialout   4,  73 oct.  26 12:42 ttyS9
crw-------  1 root    root     10, 239 oct.  26 12:42 uhid
crw-------  1 root    root     10, 223 oct.  26 12:42 uinput
crw-rw-rw-  1 root    root      1,   9 oct.  26 12:42 urandom
crw-rw----  1 vboxadd root     10,  57 oct.  26 12:43 vboxguest
crw-rw-rw-  1 vboxadd root     10,  56 oct.  26 12:43 vboxuser
crw-rw----  1 root    tty       7,   0 oct.  26 12:43 vcs
crw-rw----  1 root    tty       7,   1 oct.  26 12:43 vcs1
crw-rw----  1 root    tty       7,   2 oct.  26 12:43 vcs2
crw-rw----  1 root    tty       7,   3 oct.  26 12:43 vcs3
crw-rw----  1 root    tty       7,   4 oct.  26 12:43 vcs4
crw-rw----  1 root    tty       7,   5 oct.  26 12:43 vcs5
crw-rw----  1 root    tty       7,   6 oct.  26 12:43 vcs6
crw-rw----  1 root    tty       7,   7 oct.  26 12:43 vcs7
crw-rw----  1 root    tty       7, 128 oct.  26 12:43 vcsa
crw-rw----  1 root    tty       7, 129 oct.  26 12:43 vcsa1
crw-rw----  1 root    tty       7, 130 oct.  26 12:43 vcsa2
crw-rw----  1 root    tty       7, 131 oct.  26 12:43 vcsa3
crw-rw----  1 root    tty       7, 132 oct.  26 12:43 vcsa4
crw-rw----  1 root    tty       7, 133 oct.  26 12:43 vcsa5
crw-rw----  1 root    tty       7, 134 oct.  26 12:43 vcsa6
crw-rw----  1 root    tty       7, 135 oct.  26 12:43 vcsa7
crw-------  1 root    root     10,  63 oct.  26 12:42 vga_arbiter
crw-------  1 root    root     10, 137 oct.  26 12:42 vhci
crw-------  1 root    root     10, 238 oct.  26 12:42 vhost-net
crw-rw-rw-  1 root    root      1,   5 oct.  26 12:42 zero

On peut noter dans la sortie de la commande que certains fichiers sont de type bloc (b), tandis que d'autre sont de type caractère (c).

...
brw-rw----  1 root    disk      8,   0 oct.  26 12:43 sda
...
crw-rw-rw-  1 root    tty       5,   0 oct.  30 10:37 tty
...

La différence entre les deux repose sur le type de communication entre le système et le module. Dans le premier cas le système accède au périphérique par des coordonnées du bloc de données sur le support tandis que dans le deuxième cas la communication d'échange de données se fait octet par octet sans utiliser des tampons.

Les deux informations clefs du fichier spécial sont situées à la place de la taille d'un fichier normal et se nomment le majeur et le mineur :

Commandes

La Commande lspci

Cette commande vous renseigne sur les adaptateurs reliés aux bus PCI, AGP et PCI express :

root@ubuntu:/# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service
00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)

Pour obtenir de l'information sur un adaptateur spécifique, il convient d'utilise la même commande avec l'option -v en spécifiant l'identifiant concerné :

root@ubuntu:/# lspci -v -s 00:03.0
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
	Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter
	Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 10
	Memory at f0000000 (32-bit, non-prefetchable) [size=128K]
	I/O ports at d010 [size=8]
	Capabilities: [dc] Power Management version 2
	Capabilities: [e4] PCI-X non-bridge device
	Kernel driver in use: e1000

ou :

root@ubuntu:/# lspci -vv -s 00:03.0
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
	Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64 (63750ns min)
	Interrupt: pin A routed to IRQ 10
	Region 0: Memory at f0000000 (32-bit, non-prefetchable) [size=128K]
	Region 2: I/O ports at d010 [size=8]
	Capabilities: [dc] Power Management version 2
		Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [e4] PCI-X non-bridge device
		Command: DPERE- ERO+ RBC=512 OST=1
		Status: Dev=ff:1f.0 64bit- 133MHz- SCD- USC- DC=simple DMMRBC=2048 DMOST=1 DMCRS=8 RSCEM- 266MHz- 533MHz-
	Kernel driver in use: e1000

Options de la commande

Les options de cette commande sont :

root@ubuntu:/# lspci --help
lspci: invalid option -- '-'
Usage: lspci [<switches>]

Basic display modes:
-mm		Produce machine-readable output (single -m for an obsolete format)
-t		Show bus tree

Display options:
-v		Be verbose (-vv for very verbose)
-k		Show kernel drivers handling each device
-x		Show hex-dump of the standard part of the config space
-xxx		Show hex-dump of the whole config space (dangerous; root only)
-xxxx		Show hex-dump of the 4096-byte extended config space (root only)
-b		Bus-centric view (addresses and IRQ's as seen by the bus)
-D		Always show domain numbers

Resolving of device ID's to names:
-n		Show numeric ID's
-nn		Show both textual and numeric ID's (names & numbers)
-q		Query the PCI ID database for unknown ID's via DNS
-qq		As above, but re-query locally cached entries
-Q		Query the PCI ID database for all ID's via DNS

Selection of devices:
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]	Show only devices in selected slots
-d [<vendor>]:[<device>]			Show only devices with specified ID's

Other options:
-i <file>	Use specified ID database instead of /usr/share/misc/pci.ids.gz
-p <file>	Look up kernel modules in a given file instead of default modules.pcimap
-M		Enable `bus mapping' mode (dangerous; root only)

PCI access options:
-A <method>	Use the specified PCI access method (see `-A help' for a list)
-O <par>=<val>	Set PCI access parameter (see `-O help' for a list)
-G		Enable PCI access debugging
-H <mode>	Use direct hardware access (<mode> = 1 or 2)
-F <file>	Read PCI configuration dump from a given file

La Commande lsusb

Cette commande vous renseigne sur les adaptateurs reliés au bus usb :

root@ubuntu:/# lsusb
Bus 001 Device 004: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Pour obtenir de l'information sur un périphérique usb, il convient d'utiliser la même commande avec l'option -d en spécifiant l'identifiant concerné.

Options de la commande

Les options de cette commande sont :

root@ubuntu:/# lsusb --help
Usage: lsusb [options]...
List USB devices
  -v, --verbose
      Increase verbosity (show descriptors)
  -s [[bus]:][devnum]
      Show only devices with specified device and/or
      bus numbers (in decimal)
  -d vendor:[product]
      Show only devices with the specified vendor and
      product ID numbers (in hexadecimal)
  -D device
      Selects which device lsusb will examine
  -t, --tree
      Dump the physical USB device hierarchy as a tree
  -V, --version
      Show version of program
  -h, --help
      Show usage and help

La Commande dmidecode

La commande dmidecode lit la table DMI (Desktop Management Interface) aussi appelée SMBIOS (System Management BIOS) et fourni les informations sur :

root@ubuntu:/# dmidecode
# dmidecode 2.12
SMBIOS 2.5 present.
10 structures occupying 449 bytes.
Table at 0x000E1000.

Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
	Vendor: innotek GmbH
	Version: VirtualBox
	Release Date: 12/01/2006
	Address: 0xE0000
	Runtime Size: 128 kB
	ROM Size: 128 kB
	Characteristics:
		ISA is supported
		PCI is supported
		Boot from CD is supported
		Selectable boot is supported
		8042 keyboard services are supported (int 9h)
		CGA/mono video services are supported (int 10h)
		ACPI is supported

Handle 0x0001, DMI type 1, 27 bytes
System Information
	Manufacturer: innotek GmbH
	Product Name: VirtualBox
	Version: 1.2
	Serial Number: 0
	UUID: 6A0ED5A5-4B26-4495-9D69-13EEAE8536A5
	Wake-up Type: Power Switch
	SKU Number: Not Specified
	Family: Virtual Machine

Handle 0x0008, DMI type 2, 15 bytes
Base Board Information
	Manufacturer: Oracle Corporation
	Product Name: VirtualBox
	Version: 1.2
	Serial Number: 0
	Asset Tag: Not Specified
	Features:
		Board is a hosting board
	Location In Chassis: Not Specified
	Chassis Handle: 0x0003
	Type: Motherboard
	Contained Object Handles: 0

Handle 0x0003, DMI type 3, 13 bytes
Chassis Information
	Manufacturer: Oracle Corporation
	Type: Other
	Lock: Not Present
	Version: Not Specified
	Serial Number: Not Specified
	Asset Tag: Not Specified
	Boot-up State: Safe
	Power Supply State: Safe
	Thermal State: Safe
	Security Status: None

Handle 0x0007, DMI type 126, 42 bytes
Inactive

Handle 0x0005, DMI type 126, 15 bytes
Inactive

Handle 0x0006, DMI type 126, 28 bytes
Inactive

Handle 0x0002, DMI type 11, 7 bytes
OEM Strings
	String 1: vboxVer_4.3.18
	String 2: vboxRev_96516

Handle 0x0008, DMI type 128, 8 bytes
OEM-specific Type
	Header and Data:
		80 08 08 00 6B E7 22 00

Handle 0xFEFF, DMI type 127, 4 bytes
End Of Table

Options de la commande

Les options de cette commande sont :

root@ubuntu:/# dmidecode --help
Usage: dmidecode [OPTIONS]
Options are:
 -d, --dev-mem FILE     Read memory from device FILE (default: /dev/mem)
 -h, --help             Display this help text and exit
 -q, --quiet            Less verbose output
 -s, --string KEYWORD   Only display the value of the given DMI string
 -t, --type TYPE        Only display the entries of given type
 -u, --dump             Do not decode the entries
     --dump-bin FILE    Dump the DMI data to a binary file
     --from-dump FILE   Read the DMI data from a binary file
 -V, --version          Display the version and exit

Répertoire /proc

Le répertoire /proc contient des fichiers et des répertoires virtuels. Le contenu de ces fichiers est créé dynamiquement lors de la consultation. Seul root peut consulter la totalité des informations dans le répertoire /proc. Le répertoire /proc contient des fichiers pour nous renseigner sur le matériel présent dans la machine.

Répertoires

ide/scsi

Ce répertoire contient des répertoires dans lesquels se trouvent des informations sur la capacité, le type et la géométrie des disques.

acpi

Ce répertoire contient des informations sur la gestion de l'énérgie, les températures, les vitesses de ventilateurs, la charge des batteries.

bus

Ce répertoire contient un sous-répertoire par bus.

net

Ce répertoire contient des informations sur le réseau.

sys

Ce répertoire contient des paramètres du noyau. Certains des fichiers dans ce répertoire sont accessibles en écriture par root en temps réel. Par exemple pour éviter des attaques réseau DoS utilisant la commande ping, saisissez la commande suivante :

#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all [Entrée]

Cette commande a pour résultat d'ignorer les reqûetes ping.

Les fichiers dans le répertoire /proc/sys peuvent être administrés par la commande sysctl en temps réel.

La commande sysctl

La commande sysctl applique les règles consignés dans le fichier /etc/sysctl.conf au démarrage de la machine.

Saisissez la commande :

root@ubuntu:/# cat /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#
Options de la commande

Les options de la commande sysctl sont :

root@ubuntu:/# sysctl --help

Usage:
 sysctl [options] [variable[=value] ...]

Options:
  -a, --all            display all variables
  -A                   alias of -a
  -X                   alias of -a
      --deprecated     include deprecated parameters to listing
  -b, --binary         print value without new line
  -e, --ignore         ignore unknown variables errors
  -N, --names          print variable names without values
  -n, --values         print only values of a variables
  -p, --load[=<file>]  read values from file
  -f                   alias of -p
      --system         read values from all system directories
  -r, --pattern <expression>
                       select setting that match expression
  -q, --quiet          do not echo variable set
  -w, --write          enable writing a value to variable
  -o                   does nothing
  -x                   does nothing
  -d                   alias of -h

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see sysctl(8).

Fichiers

Processeur

root@ubuntu:/# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
stepping	: 9
microcode	: 0x19
cpu MHz		: 2287.852
cache size	: 6144 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fdiv_bug	: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 5
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc pni monitor ssse3 lahf_lm
bogomips	: 4575.70
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

Interruptions système

root@ubuntu:/# cat /proc/interrupts
           CPU0       
  0:         41    XT-PIC-XT-PIC    timer
  1:       5144    XT-PIC-XT-PIC    i8042
  2:          0    XT-PIC-XT-PIC    cascade
  8:          0    XT-PIC-XT-PIC    rtc0
  9:      77518    XT-PIC-XT-PIC    acpi, vboxguest
 10:      12232    XT-PIC-XT-PIC    eth0
 11:      11811    XT-PIC-XT-PIC    ohci_hcd:usb1, ahci, snd_intel8x0
 12:      12845    XT-PIC-XT-PIC    i8042
 14:          0    XT-PIC-XT-PIC    ata_piix
 15:      22657    XT-PIC-XT-PIC    ata_piix
NMI:          0   Non-maskable interrupts
LOC:     942810   Local timer interrupts
SPU:          0   Spurious interrupts
PMI:          0   Performance monitoring interrupts
IWI:      11469   IRQ work interrupts
RTR:          0   APIC ICR read retries
RES:          0   Rescheduling interrupts
CAL:          0   Function call interrupts
TLB:          0   TLB shootdowns
TRM:          0   Thermal event interrupts
THR:          0   Threshold APIC interrupts
MCE:          0   Machine check exceptions
MCP:         74   Machine check polls
ERR:          0
MIS:          0

Canaux DMA

root@ubuntu:/# cat /proc/dma
 4: cascade

Plages d'entrée/sortie

root@ubuntu:/# cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
0070-0071 : rtc_cmos
  0070-0071 : rtc0
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:01.1
  0170-0177 : ata_piix
01f0-01f7 : 0000:00:01.1
  01f0-01f7 : ata_piix
0376-0376 : 0000:00:01.1
  0376-0376 : ata_piix
03c0-03df : vga+
03f6-03f6 : 0000:00:01.1
  03f6-03f6 : ata_piix
0cf8-0cff : PCI conf1
4000-4003 : ACPI PM1a_EVT_BLK
4004-4005 : ACPI PM1a_CNT_BLK
4008-400b : ACPI PM_TMR
4020-4021 : ACPI GPE0_BLK
d000-d00f : 0000:00:01.1
  d000-d00f : ata_piix
d010-d017 : 0000:00:03.0
  d010-d017 : e1000
d020-d03f : 0000:00:04.0
d100-d1ff : 0000:00:05.0
  d100-d1ff : Intel 82801AA-ICH
d200-d23f : 0000:00:05.0
  d200-d23f : Intel 82801AA-ICH
d240-d247 : 0000:00:0d.0
  d240-d247 : ahci
d250-d257 : 0000:00:0d.0
  d250-d257 : ahci
d260-d26f : 0000:00:0d.0
  d260-d26f : ahci

Périphériques

root@ubuntu:/# cat /proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  5 ttyprintk
  6 lp
  7 vcs
 10 misc
 13 input
 21 sg
 29 fb
 99 ppdev
108 ppp
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
216 rfcomm
226 drm
251 hidraw
252 bsg
253 watchdog
254 rtc

Block devices:
  1 ramdisk
259 blkext
  7 loop
  8 sd
  9 md
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
252 device-mapper
253 virtblk
254 mdp

Modules

root@ubuntu:/# cat /proc/modules
vboxsf 42558 0 - Live 0xf9f0e000 (OF)
bnep 18895 2 - Live 0xf872e000
rfcomm 53664 0 - Live 0xf855c000
bluetooth 342206 10 bnep,rfcomm, Live 0xf9da2000
snd_intel8x0 33110 2 - Live 0xf8612000
snd_ac97_codec 105709 1 snd_intel8x0, Live 0xf86ba000
ac97_bus 12642 1 snd_ac97_codec, Live 0xf848c000
snd_pcm 85501 2 snd_intel8x0,snd_ac97_codec, Live 0xf86d8000
snd_page_alloc 14230 2 snd_intel8x0,snd_pcm, Live 0xf857d000
snd_seq_midi 13132 0 - Live 0xf8578000
snd_seq_midi_event 14475 1 snd_seq_midi, Live 0xf8550000
joydev 17101 0 - Live 0xf8556000
snd_rawmidi 25135 1 snd_seq_midi, Live 0xf8570000
snd_seq 55383 2 snd_seq_midi,snd_seq_midi_event, Live 0xf8516000
snd_seq_device 14137 3 snd_seq_midi,snd_rawmidi,snd_seq, Live 0xf860d000
vboxvideo 12578 0 - Live 0xf84b2000 (OF)
snd_timer 28584 2 snd_pcm,snd_seq, Live 0xf853e000
drm 244037 1 vboxvideo, Live 0xf85d0000
snd 60871 12 snd_intel8x0,snd_ac97_codec,snd_pcm,snd_seq_midi,snd_rawmidi,snd_seq,snd_seq_device,snd_timer, Live 0xf84f8000
vboxguest 219348 7 vboxsf, Live 0xf8594000 (OF)
serio_raw 13230 0 - Live 0xf8491000
i2c_piix4 17723 0 - Live 0xf850b000
mac_hid 13037 0 - Live 0xf8413000
soundcore 12600 1 snd, Live 0xf84b8000
parport_pc 31981 0 - Live 0xf8454000
ppdev 17391 0 - Live 0xf844b000
lp 13299 0 - Live 0xf840e000
parport 40836 3 parport_pc,ppdev,lp, Live 0xf87eb000
hid_generic 12492 0 - Live 0xf8409000
usbhid 46997 0 - Live 0xf8421000
hid 87604 2 hid_generic,usbhid, Live 0xf84e1000
e1000 128503 0 - Live 0xf846b000
usb_storage 48417 0 - Live 0xf845e000
psmouse 91329 0 - Live 0xf849a000
ahci 25579 2 - Live 0xf8433000
libahci 27082 1 ahci, Live 0xf843e000

Statitiques de l'utilisation des disques

root@ubuntu:/# cat /proc/diskstats
   1       0 ram0 0 0 0 0 0 0 0 0 0 0 0
   1       1 ram1 0 0 0 0 0 0 0 0 0 0 0
   1       2 ram2 0 0 0 0 0 0 0 0 0 0 0
   1       3 ram3 0 0 0 0 0 0 0 0 0 0 0
   1       4 ram4 0 0 0 0 0 0 0 0 0 0 0
   1       5 ram5 0 0 0 0 0 0 0 0 0 0 0
   1       6 ram6 0 0 0 0 0 0 0 0 0 0 0
   1       7 ram7 0 0 0 0 0 0 0 0 0 0 0
   1       8 ram8 0 0 0 0 0 0 0 0 0 0 0
   1       9 ram9 0 0 0 0 0 0 0 0 0 0 0
   1      10 ram10 0 0 0 0 0 0 0 0 0 0 0
   1      11 ram11 0 0 0 0 0 0 0 0 0 0 0
   1      12 ram12 0 0 0 0 0 0 0 0 0 0 0
   1      13 ram13 0 0 0 0 0 0 0 0 0 0 0
   1      14 ram14 0 0 0 0 0 0 0 0 0 0 0
   1      15 ram15 0 0 0 0 0 0 0 0 0 0 0
   7       0 loop0 0 0 0 0 0 0 0 0 0 0 0
   7       1 loop1 0 0 0 0 0 0 0 0 0 0 0
   7       2 loop2 0 0 0 0 0 0 0 0 0 0 0
   7       3 loop3 0 0 0 0 0 0 0 0 0 0 0
   7       4 loop4 0 0 0 0 0 0 0 0 0 0 0
   7       5 loop5 0 0 0 0 0 0 0 0 0 0 0
   7       6 loop6 0 0 0 0 0 0 0 0 0 0 0
   7       7 loop7 0 0 0 0 0 0 0 0 0 0 0
  11       0 sr0 173 1 696 976 0 0 0 0 0 688 976
   8       0 sda 9983 7064 830510 967460 3073 3569 68120 10912 0 52328 978192
   8       1 sda1 9637 7033 827506 966404 3008 3569 68120 10776 0 52128 977000
   8       2 sda2 4 0 20 76 0 0 0 0 0 76 76
   8       5 sda5 161 31 1536 768 0 0 0 0 0 768 768
   8      16 sdb 185 0 1480 28 0 0 0 0 0 28 28

Partitions

root@ubuntu:/# cat /proc/partitions
major minor  #blocks  name

  11        0    1048574 sr0
   8        0   20971520 sda
   8        1    4881408 sda1
   8        2          1 sda2
   8        5    2096128 sda5
   8       16   10485760 sdb

Espaces de pagination

root@ubuntu:/# cat /proc/swaps
Filename				Type		Size	Used	Priority
/dev/sda5                               partition	2096124	0	-1

Statistiques d'utilisation du processeur

root@ubuntu:/# cat /proc/loadavg
0.45 0.31 0.21 4/334 3129

Statistiques d'utilisation de la mémoire

root@ubuntu:/# cat /proc/meminfo
MemTotal:        2015632 kB
MemFree:         1112240 kB
Buffers:           42636 kB
Cached:           388348 kB
SwapCached:            0 kB
Active:           523512 kB
Inactive:         334968 kB
Active(anon):     428308 kB
Inactive(anon):     9144 kB
Active(file):      95204 kB
Inactive(file):   325824 kB
Unevictable:          32 kB
Mlocked:              32 kB
HighTotal:       1134536 kB
HighFree:         620332 kB
LowTotal:         881096 kB
LowFree:          491908 kB
SwapTotal:       2096124 kB
SwapFree:        2096124 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        427524 kB
Mapped:            96456 kB
Shmem:              9960 kB
Slab:              25128 kB
SReclaimable:      13560 kB
SUnreclaim:        11568 kB
KernelStack:        2672 kB
PageTables:         7132 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     3103940 kB
Committed_AS:    2650948 kB
VmallocTotal:     122880 kB
VmallocUsed:       24548 kB
VmallocChunk:      95120 kB
HardwareCorrupted:     0 kB
AnonHugePages:    174080 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       20472 kB
DirectMap2M:      892928 kB

Version du noyau

root@ubuntu:/# cat /proc/version
Linux version 3.13.0-32-generic (buildd@roseapple) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC 2014

Interprétation des informations dans /proc

Les informations brutes stockées dans /proc peuvent être interprétées grâce à l'utilisation des commandes dites de gestion des performances :

Sous Debian, certains outils tels iostat, vmstat, mpstat, sar … ne sont pas installés par défaut. Il convient donc de les installer à l'aide de la commande apt-get :

root@ubuntu:/# apt-get install sysstat hdparm
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances       
Lecture des informations d'état... Fait
hdparm est déjà la plus récente version disponible.
Paquets suggérés :
  isag
Les NOUVEAUX paquets suivants seront installés :
  sysstat
0 mis à jour, 1 nouvellement installés, 0 à enlever et 148 non mis à jour.
Il est nécessaire de prendre 271 ko dans les archives.
Après cette opération, 868 ko d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer ? [O/n] o
Réception de : 1 http://fr.archive.ubuntu.com/ubuntu/ trusty/main sysstat i386 10.2.0-1 [271 kB]
271 ko réceptionnés en 25s (10,5 ko/s)                                         
Préconfiguration des paquets...
Sélection du paquet sysstat précédemment désélectionné.
(Lecture de la base de données... 167641 fichiers et répertoires déjà installés.)
Préparation du décompactage de .../sysstat_10.2.0-1_i386.deb ...
Décompactage de sysstat (10.2.0-1) ...
Traitement déclenché pour  man-db (2.6.7.1-1) ...
Traitement déclenché pour  doc-base (0.10.5) ...
Traitement en cours 1 added doc-base file...
Traitement déclenché pour  ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Paramétrage de sysstat (10.2.0-1) ...

Creating config file /etc/default/sysstat with new version
update-alternatives: utilisation de « /usr/bin/sar.sysstat » pour fournir « /usr/bin/sar » (sar) en mode automatique
Traitement déclenché pour  ureadahead (0.100.0-16) ...

Commandes

free

La commande free permet de donner l’état de la mémoire totale, libre, partagée, swap et bufferisée. Saisissez donc la commande suivante :

root@debian:~# free -m
             total       used       free     shared    buffers     cached
Mem:          1010        658        351          0         54        272
-/+ buffers/cache:        331        679
Swap:         1906          0       1906

root@ubuntu:/# free -m
             total       used       free     shared    buffers     cached
Mem:          1968        947       1020          9         44        436
-/+ buffers/cache:        466       1501
Swap:         2046          0       2046

Dans le cas de cet exemple, nous pouvons constater que l’affichage montre :

La ligne -/+ buffers/cache: indique que les applications utilisent 466 Mo et qu’elles disposent de 1501 Mo de mémoire libre (44+436+1020).

Les options de cette commande sont :

root@ubuntu:/# free --help

Usage:
 free [options]

Options:
 -b, --bytes         show output in bytes
 -k, --kilo          show output in kilobytes
 -m, --mega          show output in megabytes
 -g, --giga          show output in gigabytes
     --tera          show output in terabytes
 -h, --human         show human-readable output
     --si            use powers of 1000 not 1024
 -l, --lohi          show detailed low and high memory statistics
 -o, --old           use old format (without -/+buffers/cache line)
 -t, --total         show total for RAM + swap
 -s N, --seconds N   repeat printing every N seconds
 -c N, --count N     repeat printing N times, then exit

     --help     display this help and exit
 -V, --version  output version information and exit

For more details see free(1).
uptime ou w

Chacune des ces commandes indique la charge moyenne du ou des processeurs depuis 1 minute, 5 minutes et 15 minutes :

root@ubuntu:/# uptime
 11:33:55 up  6:16,  2 users,  load average: 0,07, 0,31, 0,26
root@ubuntu:/# w
 11:34:12 up  6:16,  2 users,  load average: 0,19, 0,32, 0,27
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
trainee  :0       :0               dim.12   ?xdm?  38:12   0.21s init --user
trainee  pts/12   :0               dim.12    4.00s  0.13s 19.68s gnome-terminal

Les valeurs load average ou charge moyenne indiquent le nombre moyen de processus en cours de traitement ou en attente pour la période concernée.

Par exemple si les valeurs sur un système muni d'un seul processeur étaient 3,48 4,00 3,85 ceci indiquerait que le processeur a du mal à traiter les processus mettant en moyenne :

Les options de ces commandes sont :

root@ubuntu:/# uptime --help

Usage:
 uptime [options]

Options:
 -p, --pretty   show uptime in pretty format
 -h, --help     display this help and exit
 -s, --since    system up since
 -V, --version  output version information and exit

For more details see uptime(1).
root@ubuntu:/# w --help

Usage:
 w [options]

Options:
 -h, --no-header     do not print header
 -u, --no-current    ignore current process username
 -s, --short         short format
 -f, --from          show remote hostname field
 -o, --old-style     old style output
 -i, --ip-addr       display IP address instead of hostname (if possible)

     --help     display this help and exit
 -V, --version  output version information and exit

For more details see w(1).
iostat

La commande iostat affiche des statistiques sur l'utilisation des disques, des terminaux et des lecteurs de cartouche :

root@ubuntu:/# iostat
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9,77    0,02    1,44    0,17    0,00   88,61

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0,01         0,02         0,00        348          0
sda               0,79        21,32         4,05     480559      91308
sdb               0,01         0,03         0,00        740          0

Au-dessous de la première ligne indiquant la version du noyau du système et son nom d'hôte ainsi que la date actuelle, iostat affiche une vue d'ensemble de l'utilisation CPU moyenne du système depuis le dernier démarrage. Le rapport d'utilisation du CPU inclut les pourcentages suivants :

Notez la valeur de %iowait. Dans le cas où ce pourcentage est trop élévé, ceci indique que le processeur passe son temps à attendre les entrées et les sorties de disque.

Pour surveiller la vitesse des entrées et des sorties du disque, vous pouvez utiliser la commande hdparm :

root@ubuntu:/# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads: 220 MB in  3.06 seconds =  71.83 MB/sec

Au-dessous du rapport d'utilisation du CPU figure le rapport d'utilisation des périphériques. Ce dernier contient une ligne pour chaque périphérique disque du système et inclut les informations suivantes :

Les options de cette commande sont :

root@ubuntu:/# iostat --help
Utilisation : iostat [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]
[ -j { ID | LABEL | PATH | UUID | … } ]
[ [ -T ] -g <nom_groupe> ] [ -p [ <périph> [,…] | ALL ] ]
vmstat

La commande vmstat affiche des statistiques sur la mémoire, la pagination et la charge ponctuelle du processeur :

root@ubuntu:/# vmstat 1 10
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 994516  45888 460528    0    0    32     4   54  562 10  1 89  0  0
 0  0      0 994464  45888 460560    0    0     0     0   74  929 15  3 82  0  0
 0  0      0 994472  45888 460560    0    0     0     0   75 1144 11  7 82  0  0
 0  0      0 994488  45888 460560    0    0     0     0   73 1175 13  5 82  0  0
 1  0      0 990772  45888 460560    0    0     0     0  285 3138 38 13 49  0  0
 1  0      0 986200  45888 460560    0    0     0     0  339 4459 54 16 30  0  0
 0  0      0 986204  45896 460564    0    0     0    24   60  949  9  3 88  0  0
 0  0      0 986204  45896 460564    0    0     0     0   81 1209 12  7 81  0  0
 1  0      0 986056  45896 460564    0    0     0     0  129 2366 22  9 68  0  0
 0  0      0 986072  45896 460564    0    0     0     0  227 4662 50 17 34  0  0

La première ligne subdivise le champ en six catégories à savoir : processus, mémoire, swap, E/S, système et CPU sur lesquelles elle donne des statistiques. La seconde ligne identifie de manière encore plus détaillée chacun des champs, permettant ainsi de parcourir simplement et rapidement l'ensemble des données lors de la recherche de statistiques spécifiques.

Les champs relatifs aux processus sont les suivants :

Les champs relatifs à la mémoire sont les suivants :

Les champs relatifs au swap sont les suivants :

Les champs relatifs aux Entrées/Sorties (E/S) sont les suivants :

Les champs relatifs au système sont les suivants :

Les champs relatifs au CPU sont les suivants :

Les options de cette commande sont :

root@ubuntu:/# vmstat --help

Usage:
 vmstat [options] [delay [count]]

Options:
 -a, --active           active/inactive memory
 -f, --forks            number of forks since boot
 -m, --slabs            slabinfo
 -n, --one-header       do not redisplay header
 -s, --stats            event counter statistics
 -d, --disk             disk statistics
 -D, --disk-sum         summarize disk statistics
 -p, --partition <dev>  partition specific statistics
 -S, --unit <char>      define display unit
 -w, --wide             wide output

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see vmstat(8).

Par défaut la commande vmstat affiche des informations depuis le démarrage du système.

mpstat

La commande mpstat affiche des statistiques détaillées sur le CPU :

root@ubuntu:/# mpstat
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:38:10     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:38:10     all    9,84    0,02    1,47    0,18    0,00    0,01    0,00    0,00    0,00   88,48

Dans le cas où vous avez plusieurs processeurs ou coeurs, vous pouvez visualiser ces mêmes informations par unité de traitement :

root@ubuntu:/# mpstat -P ALL
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:38:35     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:38:35     all    9,86    0,02    1,48    0,18    0,00    0,01    0,00    0,00    0,00   88,46
11:38:35       0    9,86    0,02    1,48    0,18    0,00    0,01    0,00    0,00    0,00   88,46

Pour afficher 5 jeux de statistiques à des intervales de 2 secondes pour tous les unités de traitement, il convient d'utiliser la commande suivante :

root@ubuntu:/# mpstat -P ALL 2 5
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:39:08     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:39:10     all    8,63    0,00    2,03    0,00    0,00    0,00    0,00    0,00    0,00   89,34
11:39:10       0    8,63    0,00    2,03    0,00    0,00    0,00    0,00    0,00    0,00   89,34

11:39:10     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:39:12     all    8,38    0,00    3,66    0,00    0,00    0,00    0,00    0,00    0,00   87,96
11:39:12       0    8,38    0,00    3,66    0,00    0,00    0,00    0,00    0,00    0,00   87,96

11:39:12     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:39:14     all   35,71    0,00    6,63    0,00    0,00    0,00    0,00    0,00    0,00   57,65
11:39:14       0   35,71    0,00    6,63    0,00    0,00    0,00    0,00    0,00    0,00   57,65

11:39:14     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:39:16     all   15,23    0,00    3,55    0,00    0,00    0,00    0,00    0,00    0,00   81,22
11:39:16       0   15,23    0,00    3,55    0,00    0,00    0,00    0,00    0,00    0,00   81,22

11:39:16     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
11:39:18     all   14,57    0,00    4,52    0,00    0,00    0,00    0,00    0,00    0,00   80,90
11:39:18       0   14,57    0,00    4,52    0,00    0,00    0,00    0,00    0,00    0,00   80,90

Moyenne :   CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
Moyenne :   all   16,53    0,00    4,08    0,00    0,00    0,00    0,00    0,00    0,00   79,39
Moyenne :     0   16,53    0,00    4,08    0,00    0,00    0,00    0,00    0,00    0,00   79,39

Les options de cette commande sont :

root@ubuntu:/# mpstat --help
Utilisation : mpstat [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ]
[ -P { <cpu> [,…] | ON | ALL } ]
sar

La commande sar permet de surveiller toutes les ressources du système selon l'option qui est passée en argument à la commande. Quelques options importantes sont :

Option Description
-u Pourcentage d'utilisation du CPU
-q Nombre de processus en attente
-r Utilisation de la mémoire centrale
-w Surveillance du swapping
-p Surveillance de la pagination
-b Utilisation des tampons
-d Utilisation des disques

La commande /usr/lib/sysstat/sadc permet de collecter les informations.

root@ubuntu:/# ls /usr/lib/sysstat/
debian-sa1  sa1  sa2  sadc

Le script /usr/lib/sysstat/sa1 exécute la commande /usr/lib/sysstat/sadc. Ce script prend deux options :

Option Description
-t L'interval entre les collectes
-n Nombre de collectes

Le script /usr/lib/sysstat/sa2 exécute la commande sar et consigne les informations dans un fichier au format /var/log/sysstat/sar<jj>.

Pour pouvoir fonctionner correctement, ces scripts doivent être appelés par cron.

Pour constater ce fonctionnement manuellement saisissez la commande suivante :

root@ubuntu:/# /usr/lib/sysstat/sa1 5 5
root@ubuntu:/# 

Saisissez ensuite les commandes suivantes :

root@ubuntu:/# sar
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:40:59        CPU     %user     %nice   %system   %iowait    %steal     %idle
11:41:04        all      9,48      0,00      2,82      0,00      0,00     87,70
11:41:09        all     25,98      0,00     10,10      0,21      0,00     63,71
11:41:14        all     19,23      0,00      7,29      0,00      0,00     73,48
11:41:19        all      5,22      0,00      1,61      2,21      0,00     90,96
Moyenne :      all     14,90      0,00      5,42      0,61      0,00     79,07
root@ubuntu:/# sar -u 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:45:38        CPU     %user     %nice   %system   %iowait    %steal     %idle
11:45:43        all     21,82      0,00      4,85      0,00      0,00     73,33
11:45:48        all     20,88      0,00      7,63      0,00      0,00     71,49
11:45:53        all     29,09      0,00      8,28      0,00      0,00     62,63
Moyenne :      all     23,92      0,00      6,92      0,00      0,00     69,15
root@ubuntu:/# sar -r 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:45:56    kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
11:46:01      1000624   1015008     50,36     46288    460760   2740600     66,65    577716    385612         0
11:46:06      1000652   1014980     50,36     46288    460760   2740600     66,65    577720    385612         0
11:46:11      1000620   1015012     50,36     46288    460760   2740600     66,65    577728    385612         0
Moyenne :    1000632   1015000     50,36     46288    460760   2740600     66,65    577721    385612         0
root@ubuntu:/# sar -w 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:46:14       proc/s   cswch/s
11:46:19         0,00   2965,50
11:46:24         0,00   2040,08
11:46:29         0,00   2552,95
Moyenne :       0,00   2517,32
root@ubuntu:/# sar -b 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:46:32          tps      rtps      wtps   bread/s   bwrtn/s
11:46:37         0,61      0,00      0,61      0,00      4,91
11:46:42         0,00      0,00      0,00      0,00      0,00
11:46:47         0,00      0,00      0,00      0,00      0,00
Moyenne :       0,20      0,00      0,20      0,00      1,63
root@ubuntu:/# sar -d 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:46:49          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
11:46:54      dev11-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:46:54       dev8-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:46:54      dev8-16      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00

11:46:54          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
11:46:59      dev11-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:46:59       dev8-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:46:59      dev8-16      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00

11:46:59          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
11:47:04      dev11-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:47:04       dev8-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
11:47:04      dev8-16      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00

Moyenne :        DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
Moyenne :    dev11-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
Moyenne :     dev8-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
Moyenne :    dev8-16      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00
root@ubuntu:/# sar -p 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:47:19        CPU     %user     %nice   %system   %iowait    %steal     %idle
11:47:24        all     23,05      0,00      6,38      0,00      0,00     70,58
11:47:29        all     26,12      0,00      7,96      0,00      0,00     65,92
11:47:34        all     25,25      0,00      7,27      0,00      0,00     67,47
Moyenne :      all     24,81      0,00      7,21      0,00      0,00     67,98
root@ubuntu:/# sar -v 5 3
Linux 3.13.0-32-generic (ubuntu) 	30/10/2014 	_i686_	(1 CPU)

11:47:37    dentunusd   file-nr  inode-nr    pty-nr
11:47:42        20946      6912     22812        23
11:47:47        20946      6912     22812        23
11:47:52        20946      6912     22812        23
Moyenne :      20946      6912     22812        23

Les options de cette commande sont :

root@ubuntu:/# sar --help
Utilisation : sar [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -A ] [ -B ] [ -b ] [ -C ] [ -d ] [ -F ] [-H ] [ -h ] [ -p ] [ -q ] [ -R ]
[ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ]
[ -I { <entier> [,…] | SUM | ALL | XALL } ] [ -P { <cpu> [,…] | ALL } ]
[ -m { <mot-clef> [,…] | ALL } ] [ -n { <mot-clef> [,…] | ALL } ]
[ -j { ID | LABEL | PATH | UUID | … } ]
[ -f [ <nom_fichier> ] | -o [ <nom_fichier> ] | -[0-9]+ ]
[ -i <intervalle> ] [ -s [ <hh:mm:ss> ] ] [ -e [ <hh:mm:ss> ] ]

Utilisation des commandes en production

Identifier un système limité par le processeur

Dans ce cas utilisez les commandes suivantes :

Identifier un système ayant un problème de mémoire

Dans ce cas utilisez les commandes suivantes :

Identifier un système ayant un problème d'E/S

Utilisez la commande :

Modules usb

L'USB (Universal Serial Bus) est un bus de données qui peut offrir des taux de transfert jusqu'à 480Mb/s sous la version 2.0 et jusqu'à 4.8 Gb/s sous la version 3.0. Les modules nécessaires pour les contrôleurs USB sont :

Version USB Module Nom Complet
1.0\1.1 UHCI Universal Controller Host Interface
OHCI Open Controller Host Interface
2.0 EHCI Enhanced Host Controller Interface
3.0 XHCI Extensible Host Controller Interface

Le tableau suivant liste les modules courrament chargés en fonction du périphérique utilisé :

Module Type de Périphérique
usb_storage Supports de masse
usbhid Periphériques HID (Human Interface Device)
snd-usb-audio Cartes son usb
usbvidéo Cartes vidéo et d'acquisition
irda-usb Périphériques infrarouges
usbnet Cartes réseaux usb

Les modules peuvent être chargés par un des moyens suivants :

Branchez une clef USB avant de continuer. Si vous utilisez VirtualBox, activez la clef dans votre machine virtuelle grâce aux menus Périphériques > Périphériques USB > le_nom_de_votre_clef.

udev

Le noyau Linux 2.6 est capable de détecter des périphériques branchés à chaud. Cette technologie s'appelle le hotplugging. Le hotplugging est obtenu grâce à l'utilisation de trois composants :

Les rôles de chaque composant sont les suivants :

Lors de démarrage de Linux, Udev joue un rôle important :

Udev repose sur le filesystem sysfs monté sur /sys qui permet de rendre les périphériques visibles à Udev dans l'User Space. Par exemple, lors du branchement d'une clé USB, Udev crée /dev/sdb1 automatiquement :

root@ubuntu:~# ls /dev | grep sdc
sdc
sdc1
root@ubuntu:~# ls /sys/block/sdc
alignment_offset  dev                events             ext_range  power  removable  size    subsystem
bdi               device             events_async       holders    queue  ro         slaves  trace
capability        discard_alignment  events_poll_msecs  inflight   range  sdc1       stat    uevent
root@ubuntu:~# ls /sys/block/sdc/sdc1
alignment_offset  discard_alignment  inflight   power  size   stat       trace
dev               holders            partition  ro     start  subsystem  uevent

et utilise les informations contenues dans le fichier /lib/modules/`uname -r`/modules.alias pour trouver le pilote nécessaire :

root@ubuntu:~# more /lib/modules/`uname -r`/modules.alias
# Aliases extracted from modules themselves.
alias char-major-10-134 apm
alias aes-asm aes_i586
alias aes aes_i586
alias twofish-asm twofish_i586
alias twofish twofish_i586
alias salsa20-asm salsa20_i586
alias salsa20 salsa20_i586
alias serpent serpent_sse2_i586
alias aes aesni_intel
alias x86cpu:vendor:*:family:*:model:*:feature:*0099* aesni_intel
alias crc32-pclmul crc32_pclmul
alias crc32 crc32_pclmul
alias x86cpu:vendor:*:family:*:model:*:feature:*0081* crc32_pclmul
alias pci:v0000100Bd00000515sv*sd*bc*sc*i* scx200
alias pci:v0000100Bd00000505sv*sd*bc*sc*i* scx200
alias pci:v0000100Bd00000510sv*sd*bc*sc*i* scx200
alias pci:v0000100Bd00000500sv*sd*bc*sc*i* scx200
alias x86cpu:vendor:*:family:*:model:*:feature:*0085* kvm_intel
alias x86cpu:vendor:*:family:*:model:*:feature:*00C2* kvm_amd
alias fs-msdos msdos
alias nls_tis-620 nls_cp874
alias nls_sjis nls_cp932
alias nls_gb2312 nls_cp936
alias nls_euc-kr nls_cp949
alias nls_big5 nls_cp950
alias nls_iso8859-8 nls_cp1255
alias devname:cuse cuse
alias char-major-10-203 cuse
alias fs-exofs exofs
alias fs-binfmt_misc binfmt_misc
alias fs-configfs configfs
alias fs-reiserfs reiserfs
alias fs-cramfs cramfs
--Plus--(0%)

La base de données d'Udev se trouve dans le répertoire /run/udev/data :

root@ubuntu:~# ls /run/udev/data
+acpi:ACPI0003:00  b7:1     c10:63   c21:1   c4:28  c4:56  c4:84   c7:6
+acpi:PNP0000:00   b7:2     c108:0   c21:2   c4:29  c4:57  c4:85   c7:7
+acpi:PNP0100:00   b7:3     c1:1     c21:3   c4:3   c4:58  c4:86   +hid:0003:80EE:0021.0004
+acpi:PNP0200:00   b7:4     c1:11    c226:0  c4:30  c4:59  c4:87   +input:input0
+acpi:PNP0303:00   b7:5     c116:1   c251:0  c4:31  c4:6   c4:88   +input:input1
+acpi:PNP0400:00   b7:6     c116:2   c252:0  c4:32  c4:60  c4:89   +input:input2
+acpi:PNP0A03:00   b7:7     c116:3   c252:1  c4:33  c4:61  c4:9    +input:input4
+acpi:PNP0C0A:00   b8:0     c116:33  c252:2  c4:34  c4:62  c4:90   +input:input6
+acpi:PNP0C0F:00   b8:1     c116:4   c252:3  c4:35  c4:63  c4:91   +input:input9
+acpi:PNP0C0F:01   b8:16    c116:5   c254:0  c4:36  c4:64  c4:92   n1
+acpi:PNP0C0F:02   b8:2     c1:3     c4:0    c4:37  c4:65  c4:93   n2
+acpi:PNP0C0F:03   b8:32    c13:0    c4:1    c4:38  c4:66  c4:94   +pci:0000:00:00.0
+acpi:PNP0F03:00   b8:33    c13:1    c4:10   c4:39  c4:67  c4:95   +pci:0000:00:01.0
b1:0               b8:5     c13:32   c4:11   c4:4   c4:68  c5:0    +pci:0000:00:01.1
b1:1               c10:1    c13:33   c4:12   c4:40  c4:69  c5:1    +pci:0000:00:02.0
b1:10              c10:184  c13:63   c4:13   c4:41  c4:7   c5:2    +pci:0000:00:03.0
b11:0              c10:200  c13:64   c4:14   c4:42  c4:70  c5:3    +pci:0000:00:04.0
b1:11              c10:223  c13:65   c4:15   c4:43  c4:71  c7:0    +pci:0000:00:05.0
b1:12              c10:227  c13:66   c4:16   c4:44  c4:72  c7:1    +pci:0000:00:06.0
b1:13              c10:228  c13:67   c4:17   c4:45  c4:73  c7:128  +pci:0000:00:07.0
b1:14              c10:229  c13:68   c4:18   c4:46  c4:74  c7:129  +pci:0000:00:0d.0
b1:15              c10:231  c13:69   c4:19   c4:47  c4:75  c7:130  +scsi:4:0:0:0
b1:2               c10:236  c1:4     c4:2    c4:48  c4:76  c7:131  +scsi_device:4:0:0:0
b1:3               c10:237  c1:5     c4:20   c4:49  c4:77  c7:132  +scsi_disk:4:0:0:0
b1:4               c10:56   c1:7     c4:21   c4:5   c4:78  c7:133  +scsi:host4
b1:5               c10:57   c1:8     c4:22   c4:50  c4:79  c7:134  +scsi_host:host4
b1:6               c10:58   c189:0   c4:23   c4:51  c4:8   c7:135  +scsi:target4:0:0
b1:7               c10:59   c189:4   c4:24   c4:52  c4:80  c7:2    +sound:card0
b1:8               c10:60   c189:5   c4:25   c4:53  c4:81  c7:3    +usb:1-0:1.0
b1:9               c10:61   c1:9     c4:26   c4:54  c4:82  c7:4    +usb:1-1:1.0
b7:0               c10:62   c21:0    c4:27   c4:55  c4:83  c7:5    +usb:1-2:1.0

Le périphériques sont identifiés par leurs numéros majeures:mineures :

root@ubuntu:~# ls -l /dev | grep sdc
brw-rw----  1 root    disk      8,  32 oct.  30 14:28 sdc
brw-rw----  1 root    disk      8,  33 oct.  30 14:28 sdc1

Le sdc1 a une paire majeure/mineure de 8:33. Le contenu du fichier /run/udev/data/b8:33 est :

root@ubuntu:~# cat /run/udev/data/b8:33
S:disk/by-id/usb-General_USB_Flash_Disk_0190000000008E6D-0:0-part1
S:disk/by-path/pci-0000:00:06.0-usb-0:2:1.0-scsi-0:0:0:0-part1
S:disk/by-uuid/0012-D687
W:49
I:472282722
E:ID_BUS=usb
E:ID_FS_TYPE=vfat
E:ID_FS_USAGE=filesystem
E:ID_FS_UUID=0012-D687
E:ID_FS_UUID_ENC=0012-D687
E:ID_FS_VERSION=FAT32
E:ID_INSTANCE=0:0
E:ID_MODEL=USB_Flash_Disk
E:ID_MODEL_ENC=USB\x20Flash\x20Disk\x20\x20
E:ID_MODEL_ID=800f
E:ID_PART_ENTRY_DISK=8:32
E:ID_PART_ENTRY_NUMBER=1
E:ID_PART_ENTRY_OFFSET=63
E:ID_PART_ENTRY_SCHEME=dos
E:ID_PART_ENTRY_SIZE=15669185
E:ID_PART_ENTRY_TYPE=0xb
E:ID_PART_TABLE_TYPE=dos
E:ID_PATH=pci-0000:00:06.0-usb-0:2:1.0-scsi-0:0:0:0
E:ID_PATH_TAG=pci-0000_00_06_0-usb-0_2_1_0-scsi-0_0_0_0
E:ID_REVISION=1.00
E:ID_SERIAL=General_USB_Flash_Disk_0190000000008E6D-0:0
E:ID_SERIAL_SHORT=0190000000008E6D
E:ID_TYPE=disk
E:ID_USB_DRIVER=usb-storage
E:ID_USB_INTERFACES=:080650:
E:ID_USB_INTERFACE_NUM=00
E:ID_VENDOR=General
E:ID_VENDOR_ENC=General\x20
E:ID_VENDOR_ID=6557

Voici le contenu de /dev/disk :

root@ubuntu:~# ls -lR /dev/disk
/dev/disk:
total 0
drwxr-xr-x 2 root root 200 oct.  30 14:28 by-id
drwxr-xr-x 2 root root  80 oct.  30 14:28 by-path
drwxr-xr-x 2 root root 100 oct.  30 14:28 by-uuid

/dev/disk/by-id:
total 0
lrwxrwxrwx 1 root root  9 oct.  26 12:43 ata-VBOX_CD-ROM_VB2-01700376 -> ../../sr0
lrwxrwxrwx 1 root root  9 oct.  26 12:43 ata-VBOX_HARDDISK_VB13304d26-36869aa3 -> ../../sda
lrwxrwxrwx 1 root root 10 oct.  26 12:43 ata-VBOX_HARDDISK_VB13304d26-36869aa3-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 oct.  26 12:43 ata-VBOX_HARDDISK_VB13304d26-36869aa3-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 oct.  26 12:43 ata-VBOX_HARDDISK_VB13304d26-36869aa3-part5 -> ../../sda5
lrwxrwxrwx 1 root root  9 oct.  26 12:42 ata-VBOX_HARDDISK_VBde6d0b53-81ae29a5 -> ../../sdb
lrwxrwxrwx 1 root root  9 oct.  30 14:28 usb-General_USB_Flash_Disk_0190000000008E6D-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 oct.  30 14:28 usb-General_USB_Flash_Disk_0190000000008E6D-0:0-part1 -> ../../sdc1

/dev/disk/by-path:
total 0
lrwxrwxrwx 1 root root  9 oct.  30 14:28 pci-0000:00:06.0-usb-0:2:1.0-scsi-0:0:0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 oct.  30 14:28 pci-0000:00:06.0-usb-0:2:1.0-scsi-0:0:0:0-part1 -> ../../sdc1

/dev/disk/by-uuid:
total 0
lrwxrwxrwx 1 root root 10 oct.  30 14:28 0012-D687 -> ../../sdc1
lrwxrwxrwx 1 root root 10 oct.  26 12:43 70eb8bc5-1759-433d-9797-9342a7b82cb2 -> ../../sda1
lrwxrwxrwx 1 root root 10 oct.  26 12:43 85017f2f-081d-464e-ad83-52c3c895a113 -> ../../sda5

Le fichier de configuration principal d'Udev est /etc/udev/udev.conf :

root@ubuntu:~# cat /etc/udev/udev.conf
# see udev(7) for details
#
# udevd is started in the initramfs, so when this file is modified the
# initramfs should be rebuilt.

#udev_log="info"

Les fichiers de règles se trouvent dans /lib/udev/rules.d/ :

root@ubuntu:~# ls /lib/udev/rules.d/
40-crda.rules                      75-tty-description.rules
40-gnupg.rules                     77-mm-ericsson-mbm.rules
40-hyperv-hotadd.rules             77-mm-huawei-net-port-types.rules
40-inputattach.rules               77-mm-longcheer-port-types.rules
40-libgphoto2-6.rules              77-mm-nokia-port-types.rules
40-libsane.rules                   77-mm-pcmcia-device-blacklist.rules
40-usb-media-players.rules         77-mm-platform-serial-whitelist.rules
40-usb_modeswitch.rules            77-mm-qdl-device-blacklist.rules
40-xdiagnose.rules                 77-mm-simtech-port-types.rules
42-usb-hid-pm.rules                77-mm-usb-device-blacklist.rules
50-firmware.rules                  77-mm-usb-serial-adapters-greylist.rules
50-udev-default.rules              77-mm-x22x-port-types.rules
55-dm.rules                        77-mm-zte-port-types.rules
56-hpmud.rules                     77-nm-olpc-mesh.rules
60-cdrom_id.rules                  78-graphics-card.rules
60-keyboard.rules                  78-sound-card.rules
60-pcmcia.rules                    80-drivers.rules
60-persistent-alsa.rules           80-mm-candidate.rules
60-persistent-input.rules          80-udisks2.rules
60-persistent-serial.rules         85-brltty.rules
60-persistent-storage-dm.rules     85-hdparm.rules
60-persistent-storage.rules        85-hplj10xx.rules
60-persistent-storage-tape.rules   85-keyboard-configuration.rules
60-persistent-v4l.rules            85-regulatory.rules
61-accelerometer.rules             85-usbmuxd.rules
61-gnome-bluetooth-rfkill.rules    90-alsa-restore.rules
64-btrfs.rules                     90-alsa-ucm.rules
64-xorg-xkb.rules                  90-libgpod.rules
66-xorg-synaptics-quirks.rules     90-pulseaudio.rules
69-cd-sensors.rules                95-cd-devices.rules
69-libmtp.rules                    95-udev-late.rules
69-xorg-vmmouse.rules              95-upower-battery-recall-dell.rules
69-xserver-xorg-input-wacom.rules  95-upower-battery-recall-fujitsu.rules
70-power-switch.rules              95-upower-battery-recall-gateway.rules
70-printers.rules                  95-upower-battery-recall-ibm.rules
70-uaccess.rules                   95-upower-battery-recall-lenovo.rules
71-seat.rules                      95-upower-battery-recall-toshiba.rules
73-idrac.rules                     95-upower-csr.rules
73-seat-late.rules                 95-upower-hid.rules
75-net-description.rules           95-upower-wup.rules
75-persistent-net-generator.rules  97-bluetooth-hid2hci.rules
75-probe_mtd.rules                 README

Il vous est possible d'ajouter des règles si besoin est. Dans ce cas, créez un fichier 99-local.rules est éditez-le au lieu d'éditer les fichiers existants.

Comme indique le nom de chaque fichier, le contenu est composé de règles à l'attention d'udev. Le fichier des règles par défaut est le 50-udev-default.rules :

root@ubuntu:~# cat /lib/udev/rules.d/50-udev-default.rules
# do not edit this file, it will be overwritten on update

SUBSYSTEM=="virtio-ports", KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}"

# select "system RTC" or just use the first one
SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc"
SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100"

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb"
SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id"
ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}"

ACTION!="add", GOTO="default_permissions_end"

SUBSYSTEM=="tty", KERNEL=="ptmx", GROUP="tty", MODE="0666"
SUBSYSTEM=="tty", KERNEL=="tty", GROUP="tty", MODE="0666"
SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620"
SUBSYSTEM=="vc", KERNEL=="vcs*|vcsa*", GROUP="tty"
KERNEL=="tty[A-Z]*[0-9]|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout"

SUBSYSTEM=="mem", KERNEL=="mem|kmem|port", GROUP="kmem", MODE="0640"

SUBSYSTEM=="input", KERNEL=="mouse*|mice|event*", MODE="0640"
SUBSYSTEM=="input", KERNEL=="ts[0-9]*|uinput", MODE="0640"
SUBSYSTEM=="input", KERNEL=="js[0-9]*", MODE="0644"

SUBSYSTEM=="video4linux", GROUP="video"
SUBSYSTEM=="misc", KERNEL=="agpgart", GROUP="video"
SUBSYSTEM=="graphics", GROUP="video"
SUBSYSTEM=="drm", GROUP="video"
SUBSYSTEM=="dvb", GROUP="video"

SUBSYSTEM=="sound", GROUP="audio", \
  OPTIONS+="static_node=snd/seq", OPTIONS+="static_node=snd/timer"

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664"

SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", GROUP="video"

KERNEL=="parport[0-9]*", GROUP="lp"
SUBSYSTEM=="printer", KERNEL=="lp*", GROUP="lp"
SUBSYSTEM=="ppdev", GROUP="lp"
KERNEL=="lp[0-9]*", GROUP="lp"
KERNEL=="irlpt[0-9]*", GROUP="lp"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", GROUP="lp"

SUBSYSTEM=="block", GROUP="disk"
SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
SUBSYSTEM=="block", KERNEL=="sr[0-9]*", GROUP="cdrom"
SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", GROUP="cdrom"
KERNEL=="sch[0-9]*", GROUP="cdrom"
KERNEL=="pktcdvd[0-9]*", GROUP="cdrom"
KERNEL=="pktcdvd", GROUP="cdrom"

SUBSYSTEM=="scsi_generic|scsi_tape", SUBSYSTEMS=="scsi", ATTRS{type}=="1|8", GROUP="tape"
SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="0", GROUP="disk"
KERNEL=="qft[0-9]*|nqft[0-9]*|zqft[0-9]*|nzqft[0-9]*|rawqft[0-9]*|nrawqft[0-9]*", GROUP="disk"
KERNEL=="rawctl", GROUP="disk"
SUBSYSTEM=="raw", KERNEL=="raw[0-9]*", GROUP="disk"
SUBSYSTEM=="aoe", GROUP="disk", MODE="0220"
SUBSYSTEM=="aoe", KERNEL=="err", MODE="0440"

KERNEL=="rfkill", MODE="0644"
KERNEL=="tun", MODE="0666", OPTIONS+="static_node=net/tun"

KERNEL=="fuse", MODE="0666", OPTIONS+="static_node=fuse"

LABEL="default_permissions_end"

Chaque règle prend la forme suivante :

KEY, [KEY, …] NAME [, SYMLINK]

Chaque KEY est un champ au format type=valeur qui doit correspondre à un périphérique unique. La valeur de type peut prendre plusieurs formes :

Type Description Exemples
BUS Type de bus usb, scsi, ide
KERNEL Le nom par défault du périphérique donné par le noyau hda, ttyUSB0, lp0
SUBSYSTEM Le nom noyau du sous-système, généralement identique à la valeur du BUS usb, scsi
DRIVER Le nom du pilote qui contrôle le périphérique usb-storage
ID Le numéro du périphérique sur son bus PCI bus id, USB id
PLACE Ne concerne que les périphériques USB et donne la position topologique du périphérique sur son bus S/O
SYSFS{filename} Le nom du fichier dans /sys pour le périphérique. Ce fichier contient le fabricant, le label, le numéro de série et UUID du périphérique. La vérification de jusqu'à 5 fichiers est possible par règle S/O
PROGRAM Ceci permet à Udev d'appeler un programme externe pour nommer un périphérique S/O
RESULT Valeur à comparer au résultat de PROGRAM S/O

NAME et SYMLINK sont utilisées pour stipuler ce que Udev doit faire avec le périphérique :

Type Description Exemples
NAME Le nome du nœud dans /dev S/O
SYMLINK Le ou les lien(s) symbolique(s) qui pointe(nt) vers le NAME S/O

La commande udevadm

Pour obtenir de l'information sur un périphérique il convient d'utiliser la commande udevadm qui a remplacé la commande udevinfo :

root@ubuntu:~# udevadm info --query=all -n /dev/sda
P: /devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda
N: sda
S: disk/by-id/ata-VBOX_HARDDISK_VB13304d26-36869aa3
E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB13304d26-36869aa3
E: DEVNAME=/dev/sda
E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda
E: DEVTYPE=disk
E: ID_ATA=1
E: ID_ATA_FEATURE_SET_PM=1
E: ID_ATA_FEATURE_SET_PM_ENABLED=1
E: ID_ATA_SATA=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_BUS=ata
E: ID_MODEL=VBOX_HARDDISK
E: ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_PART_TABLE_TYPE=dos
E: ID_REVISION=1.0
E: ID_SERIAL=VBOX_HARDDISK_VB13304d26-36869aa3
E: ID_SERIAL_SHORT=VB13304d26-36869aa3
E: ID_TYPE=disk
E: MAJOR=8
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=24925

La commande udevadm peut également être utilisée pour connaître toute l'information sysfs concernant un périphérique :

root@debian:~# udevadm info -a -p /sys/class/input/mouse0/

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0/input/input1/mouse0':
    KERNEL=="mouse0"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0/input/input1':
    KERNELS=="input1"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="VirtualBox USB Tablet"
    ATTRS{phys}=="usb-0000:00:06.0-1/input0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v80EEp0021e0110-e0,1,2,3,4,k110,111,112,113,114,r8,a0,1,m4,lsfw"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0':
    KERNELS=="2-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v80EEp0021d0100dc00dsc00dp00ic03isc00ip00"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1':
    KERNELS=="2-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="14"
    ATTRS{idVendor}=="80ee"
    ATTRS{idProduct}=="0021"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="2"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="VirtualBox"
    ATTRS{product}=="USB Tablet"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="40"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="8"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.32-5-686 ohci_hcd"
    ATTRS{product}=="OHCI Host Controller"
    ATTRS{serial}=="0000:00:06.0"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:06.0':
    KERNELS=="0000:00:06.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ohci_hcd"
    ATTRS{vendor}=="0x106b"
    ATTRS{device}=="0x003f"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{class}=="0x0c0310"
    ATTRS{irq}=="22"
    ATTRS{local_cpus}=="ffffffff"
    ATTRS{local_cpulist}=="0-31"
    ATTRS{modalias}=="pci:v0000106Bd0000003Fsv00000000sd00000000bc0Csc03i10"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Les options de la commande

Les options de la commande udevadm sont :

root@ubuntu:~# udevadm --help
Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]
  info         query sysfs or the udev database
  trigger      request events from the kernel
  settle       wait for the event queue to finish
  control      control the udev daemon
  monitor      listen to kernel and udev events
  hwdb         maintain the hardware database index
  test         test an event run
  test-builtin test a built-in command

root@ubuntu:~# udevadm info --help
Usage: udevadm info OPTIONS
  --query=<type>             query device information:
      name                     name of device node
      symlink                  pointing to node
      path                     sys device path
      property                 the device properties
      all                      all values
  --path=<syspath>           sys device path used for query or attribute walk
  --name=<name>              node or symlink name used for query or attribute walk
  --root                     prepend dev directory to path names
  --attribute-walk           print all key matches while walking along the chain
                             of parent devices
  --device-id-of-file=<file> print major:minor of device containing this file
  --export                   export key/value pairs
  --export-prefix            export the key name with a prefix
  --export-db                export the content of the udev database
  --cleanup-db               cleanup the udev database
  --help

Système de fichiers /sys

Le système de fichiers virtuel /sys a été introduit avec le noyau Linux 2.6. Son rôle est de décrire le matériel pour udev.

Saisissez la commande suivante :

root@ubuntu:~# ls -l /sys
total 0
drwxr-xr-x   2 root root 0 oct.  26 12:42 block
drwxr-xr-x  29 root root 0 oct.  26 12:42 bus
drwxr-xr-x  51 root root 0 oct.  26 12:42 class
drwxr-xr-x   4 root root 0 oct.  26 12:42 dev
drwxr-xr-x  15 root root 0 oct.  26 12:42 devices
drwxr-xr-x   4 root root 0 oct.  30 11:00 firmware
drwxr-xr-x   7 root root 0 oct.  26 12:42 fs
drwxr-xr-x   2 root root 0 oct.  29 15:50 hypervisor
drwxr-xr-x   7 root root 0 oct.  26 12:42 kernel
drwxr-xr-x 117 root root 0 oct.  26 12:42 module
drwxr-xr-x   2 root root 0 oct.  26 12:43 power

Chaque répertoire contient des informations :

Pour illustrer ceci, saisissez la commande suivante :

root@ubuntu:~# cat /sys/block/sda/sda1/size
9762816

Ce chiffre correspond aux nombre de secteurs.

Limitation des ressources

Les ressources disponibles aux utilisateurs peuvent être limitées par l'utilisation de la commande ulimit.

La commande ulimit gère deux types de limite, la limite hard en utilisant l'option -H et la limite soft en utilisant l'option -S. Seul root peut positionner une limite hard et ceci à condition que la limite ne dépasse pas les ressources réelles.

La limite soft est la limite imposée à l'utilisateur par défaut tandis que la limite hard est la limite que l'utilisateur peut atteindre en utilisant la commande ulimit lui-même.

L'utilisateur root peut paramétrer les limites accordées en éditant la fichier /etc/security/limits.conf :

root@ubuntu:~# cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#        - NOTE: group and wildcard limits are not applied to root.
#          To apply a limit to the root user, <domain> must be
#          the literal username root.
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#        - chroot - change root to directory (Debian-specific)
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#root            hard    core            100000
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#ftp             -       chroot          /ftp
#@student        -       maxlogins       4

# End of file

La valeur de la limite peut être un nombre ou le mot unlimited.

Par exemple, si root inscrit les deux ligne suivantes dans le fichier /etc/security/limits.conf :

...
trainee                soft        nofile          1024
trainee                hard        nofile          4096
...

la limite du nombre de fichiers ouverts simultanément par trainee est de 1 024. Par contre, trainee a la possibilité d'augmenter cette limite jusqu'à 4 096 en utilisant la commande suivante :

$ ulimit -n 4096

Pour consulter la liste des limites actuelles, il convient d'utiliser la commande ulimit avec l'option -a :

root@ubuntu:~# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15597
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 15597
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Options de la commande

Les options de ulimit sont :

root@ubuntu:~# help ulimit
ulimit: ulimit [-SHabcdefilmnpqrstuvxT] [limit]
    Modify shell resource limits.
    
    Provides control over the resources available to the shell and processes
    it creates, on systems that allow such control.
    
    Options:
      -S	use the `soft' resource limit
      -H	use the `hard' resource limit
      -a	all current limits are reported
      -b	the socket buffer size
      -c	the maximum size of core files created
      -d	the maximum size of a process's data segment
      -e	the maximum scheduling priority (`nice')
      -f	the maximum size of files written by the shell and its children
      -i	the maximum number of pending signals
      -l	the maximum size a process may lock into memory
      -m	the maximum resident set size
      -n	the maximum number of open file descriptors
      -p	the pipe buffer size
      -q	the maximum number of bytes in POSIX message queues
      -r	the maximum real-time scheduling priority
      -s	the maximum stack size
      -t	the maximum amount of cpu time in seconds
      -u	the maximum number of user processes
      -v	the size of virtual memory
      -x	the maximum number of file locks
      -T    the maximum number of threads
    
    Not all options are available on all platforms.
    
    If LIMIT is given, it is the new value of the specified resource; the
    special LIMIT values `soft', `hard', and `unlimited' stand for the
    current soft limit, the current hard limit, and no limit, respectively.
    Otherwise, the current value of the specified resource is printed.  If
    no option is given, then -f is assumed.
    
    Values are in 1024-byte increments, except for -t, which is in seconds,
    -p, which is in increments of 512 bytes, and -u, which is an unscaled
    number of processes.
    
    Exit Status:
    Returns success unless an invalid option is supplied or an error occurs.

<html>

Copyright © 2004-2016 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>