Powered By GitBook
101.1. Determine and configure hardware settings

101.1 Determine and configure hardware settings

Weight:2
Description: Candidates should be able to determine and configure fundamental system hardware.
Key Knowledge Areas:
    Tools and utilities to list various hardware information (e.g. lsusb, lspci, etc.)
    Tools and utilities to manipulate USB devices
    Conceptual understanding of sysfs, udev, dbus
The following is a partial list of the used files, terms and utilities:
    /sys/
    /proc/
    /dev/
    modprobe
    lsmod
    lspci
    lsusb
Linux treat every thing as a file. It includes programs , hardware and even processes which are running. These files are organized in directories and standardize for easier access and administration. Lets see how linux dealing with devices:

/proc

The /proc is a virtual dicretory which contains a illusionary filesystem called procfs. It does not exist on a disk. Instead, the kernel creates it in memory. It is used to provide information about the system (originally about processes).
1
[email protected]:~# ls /proc/
2
1 17 186 20 215 232 26 4043 847 diskstats pagetypeinfo
3
10 1705 187 200 2152 233 2600 452 85 dma partitions
4
1002 1717 188 201 2154 234 2625 4773 86 driver sched_debug
5
1023 1757 189 2011 2159 235 2678 5054 87 execdomains schedstat
6
1057 1761 1890 202 216 236 27 5481 873 fb scsi
7
1074 1763 1897 2026 217 237 271 5913 874 filesystems self
8
1075 1765 19 2027 218 238 272 5999 876 fs slabinfo
9
1077 1769 190 2029 219 2383 28 6 879 interrupts softirqs
10
1078 1773 1906 203 22 239 289 6000 88 iomem stat
11
1092 1780 191 2030 220 24 296 6124 881 ioports swaps
12
1095 1788 1912 2032 2200 240 32 6313 882 irq sys
13
11 1789 1913 2037 2205 241 3272 6317 885 kallsyms sysrq-trigger
14
117 1796 1915 204 221 242 33 6350 887 kcore sysvipc
15
1176 1798 1916 205 2215 243 334 6355 89 keys thread-self
16
12 18 192 206 222 2456 335 7 9 key-users timer_list
17
1221 180 1929 207 223 2474 34 729 934 kmsg timer_stats
18
13 1806 193 208 224 2477 3462 76 95 kpagecgroup tty
19
1381 181 1934 209 2241 2479 3473 77 983 kpagecount uptime
20
14 1812 194 2092 225 2490 3474 78 986 kpageflags version
21
1480 182 195 2095 2257 2496 35 79 acpi loadavg version_signature
22
15 1823 1952 21 226 25 36 8 asound locks vmallocinfo
23
1532 1826 1955 210 227 2506 370 80 buddyinfo mdstat vmstat
24
1553 183 1957 211 228 2507 3892 81 bus meminfo zoneinfo
25
1574 1836 196 212 229 2521 3907 82 cgroups misc
26
1575 1838 1962 2122 23 2525 3908 83 cmdline modules
27
1589 184 197 2124 230 2533 3909 830 consoles mounts
28
1593 1845 198 213 2301 2534 392 84 cpuinfo mpt
29
16 185 199 2138 231 2589 3981 840 crypto mtrr
30
1698 1851 2 214 2311 2599 4 843 devices net
Copied!
Some of the more important files and directories are :
/proc/1: A directory with information about process number 1. Each process has a directory below /proc with the name being its process identification number.
/proc/cpuinfo: Information about the processor, such as its type, make, model, and performance.
1
[email protected]:~# cat /proc/cpuinfo
2
processor : 0
3
vendor_id : GenuineIntel
4
cpu family : 6
5
model : 142
6
model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
7
stepping : 9
8
microcode : 0x8e
9
cpu MHz : 2904.002
10
cache size : 4096 KB
11
physical id : 0
12
siblings : 1
13
core id : 0
14
cpu cores : 1
15
apicid : 0
16
initial apicid : 0
17
fpu : yes
18
fpu_exception : yes
19
cpuid level : 22
20
wp : yes
21
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
22
bugs :
23
bogomips : 5808.00
24
clflush size : 64
25
cache_alignment : 64
26
address sizes : 43 bits physical, 48 bits virtual
27
power management:
Copied!
/proc/filesystems : Filesystems configured into the kernel.
1
[email protected]:~# cat /proc/filesystems
2
nodev sysfs
3
nodev rootfs
4
nodev ramfs
5
nodev bdev
6
nodev proc
7
nodev cpuset
8
nodev cgroup
9
nodev cgroup2
10
nodev tmpfs
11
nodev devtmpfs
12
nodev configfs
13
nodev debugfs
14
nodev tracefs
15
nodev securityfs
16
nodev sockfs
17
nodev dax
18
nodev bpf
19
nodev pipefs
20
nodev hugetlbfs
21
nodev devpts
22
ext3
23
ext2
24
ext4
25
squashfs
26
vfat
27
nodev ecryptfs
28
fuseblk
29
nodev fuse
30
nodev fusectl
31
nodev pstore
32
nodev efivarfs
33
nodev mqueue
34
nodev autofs
35
nodev binfmt_misc
36
Copied!
/proc/interrupts: Shows which interrupts are in use, and how many of each there have been.
1
[email protected]:~# cat /proc/interrupts
2
CPU0
3
0: 7 IO-APIC 2-edge timer
4
1: 7113 IO-APIC 1-edge i8042
5
8: 1 IO-APIC 8-edge rtc0
6
9: 0 IO-APIC 9-fasteoi acpi
7
12: 24004 IO-APIC 12-edge i8042
8
14: 0 IO-APIC 14-edge ata_piix
9
15: 0 IO-APIC 15-edge ata_piix
10
16: 1156 IO-APIC 16-fasteoi vmwgfx, snd_ens1371
11
17: 95298 IO-APIC 17-fasteoi ehci_hcd:usb1, ioc0
12
18: 68 IO-APIC 18-fasteoi uhci_hcd:usb2
13
19: 34519 IO-APIC 19-fasteoi ens33
14
24: 0 PCI-MSI 344064-edge PCIe PME, pciehp
15
25: 0 PCI-MSI 346112-edge PCIe PME, pciehp
16
26: 0 PCI-MSI 348160-edge PCIe PME, pciehp
17
27: 0 PCI-MSI 350208-edge PCIe PME, pciehp
18
28: 0 PCI-MSI 352256-edge PCIe PME, pciehp
19
29: 0 PCI-MSI 354304-edge PCIe PME, pciehp
20
30: 0 PCI-MSI 356352-edge PCIe PME, pciehp
21
31: 0 PCI-MSI 358400-edge PCIe PME, pciehp
22
32: 0 PCI-MSI 360448-edge PCIe PME, pciehp
23
33: 0 PCI-MSI 362496-edge PCIe PME, pciehp
24
34: 0 PCI-MSI 364544-edge PCIe PME, pciehp
25
35: 0 PCI-MSI 366592-edge PCIe PME, pciehp
26
36: 0 PCI-MSI 368640-edge PCIe PME, pciehp
27
37: 0 PCI-MSI 370688-edge PCIe PME, pciehp
28
38: 0 PCI-MSI 372736-edge PCIe PME, pciehp
29
39: 0 PCI-MSI 374784-edge PCIe PME, pciehp
30
40: 0 PCI-MSI 376832-edge PCIe PME, pciehp
31
41: 0 PCI-MSI 378880-edge PCIe PME, pciehp
32
42: 0 PCI-MSI 380928-edge PCIe PME, pciehp
33
43: 0 PCI-MSI 382976-edge PCIe PME, pciehp
34
44: 0 PCI-MSI 385024-edge PCIe PME, pciehp
35
45: 0 PCI-MSI 387072-edge PCIe PME, pciehp
36
46: 0 PCI-MSI 389120-edge PCIe PME, pciehp
37
47: 0 PCI-MSI 391168-edge PCIe PME, pciehp
38
48: 0 PCI-MSI 393216-edge PCIe PME, pciehp
39
49: 0 PCI-MSI 395264-edge PCIe PME, pciehp
40
50: 0 PCI-MSI 397312-edge PCIe PME, pciehp
41
51: 0 PCI-MSI 399360-edge PCIe PME, pciehp
42
52: 0 PCI-MSI 401408-edge PCIe PME, pciehp
43
53: 0 PCI-MSI 403456-edge PCIe PME, pciehp
44
54: 0 PCI-MSI 405504-edge PCIe PME, pciehp
45
55: 0 PCI-MSI 407552-edge PCIe PME, pciehp
46
56: 10472 PCI-MSI 1130496-edge ahci[0000:02:05.0]
47
57: 2737 PCI-MSI 129024-edge vmw_vmci
48
58: 0 PCI-MSI 129025-edge vmw_vmci
49
NMI: 0 Non-maskable interrupts
50
LOC: 1023154 Local timer interrupts
51
SPU: 0 Spurious interrupts
52
PMI: 0 Performance monitoring interrupts
53
IWI: 0 IRQ work interrupts
54
RTR: 0 APIC ICR read retries
55
RES: 0 Rescheduling interrupts
56
CAL: 0 Function call interrupts
57
TLB: 0 TLB shootdowns
58
TRM: 0 Thermal event interrupts
59
THR: 0 Threshold APIC interrupts
60
DFR: 0 Deferred Error APIC interrupts
61
MCE: 0 Machine check exceptions
62
MCP: 69 Machine check polls
63
ERR: 0
64
MIS: 0
65
PIN: 0 Posted-interrupt notification event
66
PIW: 0 Posted-interrupt wakeup event
Copied!
/proc/meminfo : Information about memory usage, both physical and swap.
1
[email protected]:~# cat /proc/meminfo
2
MemTotal: 994868 kB
3
MemFree: 114032 kB
4
MemAvailable: 189404 kB
5
Buffers: 12060 kB
6
Cached: 180636 kB
7
SwapCached: 22484 kB
8
Active: 264988 kB
9
Inactive: 271148 kB
10
Active(anon): 167716 kB
11
Inactive(anon): 179188 kB
12
Active(file): 97272 kB
13
Inactive(file): 91960 kB
14
Unevictable: 32 kB
15
Mlocked: 32 kB
16
SwapTotal: 1045500 kB
17
SwapFree: 701288 kB
18
Dirty: 0 kB
19
Writeback: 0 kB
20
AnonPages: 325912 kB
21
Mapped: 124724 kB
22
Shmem: 3464 kB
23
Slab: 73812 kB
24
SReclaimable: 27344 kB
25
SUnreclaim: 46468 kB
26
KernelStack: 9436 kB
27
PageTables: 32112 kB
28
NFS_Unstable: 0 kB
29
Bounce: 0 kB
30
WritebackTmp: 0 kB
31
CommitLimit: 1542932 kB
32
Committed_AS: 3646596 kB
33
VmallocTotal: 34359738367 kB
34
VmallocUsed: 0 kB
35
VmallocChunk: 0 kB
36
HardwareCorrupted: 0 kB
37
AnonHugePages: 157696 kB
38
ShmemHugePages: 0 kB
39
ShmemPmdMapped: 0 kB
40
CmaTotal: 0 kB
41
CmaFree: 0 kB
42
HugePages_Total: 0
43
HugePages_Free: 0
44
HugePages_Rsvd: 0
45
HugePages_Surp: 0
46
Hugepagesize: 2048 kB
47
DirectMap4k: 120704 kB
48
DirectMap2M: 927744 kB
49
DirectMap1G: 0 kB
Copied!
The way /proc virtual directory organize processes get noticed by developers and they started to use /proc for both reading and writing information. So guess what, little by little /proc become a place which stored different kind of information. Processes information, current running Kernel information, hardware information, system information. Some one should do some thing to stop this messy place and that cause /sys introducing in kernel 2.5 .

/sys

/sys it is a virtual directory with illusionary sysfs file system, which is created when system boots up and get vanished when system restarts or goes off.
sysfs introduced to specifically store system information and its components (mostly attached and installed hardware). An as it was planned for that its seems more organized and more standardize than procfs.
1
[email protected]:~# ls -l /sys/
2
total 0
3
drwxr-xr-x 2 root root 0 Oct 24 06:07 block
4
drwxr-xr-x 38 root root 0 Oct 24 06:07 bus
5
drwxr-xr-x 60 root root 0 Oct 24 06:07 class
6
drwxr-xr-x 4 root root 0 Oct 24 06:07 dev
7
drwxr-xr-x 14 root root 0 Oct 9 05:54 devices
8
drwxr-xr-x 5 root root 0 Oct 24 06:07 firmware
9
drwxr-xr-x 8 root root 0 Oct 9 05:54 fs
10
drwxr-xr-x 2 root root 0 Oct 24 06:07 hypervisor
11
drwxr-xr-x 11 root root 0 Oct 9 05:54 kernel
12
drwxr-xr-x 146 root root 0 Oct 24 06:07 module
13
drwxr-xr-x 2 root root 0 Oct 24 06:07 power
14
15
[email protected]:~# ls /sys/devices/
16
breakpoint isa msr platform software tracepoint
17
cpu LNXSYSTM:00 pci0000:00 pnp0 system virtual
Copied!
sysfs hasn't caused all the stuff move from /proc to /sys , they still exist in /proc but /sys gives us a better view of current data.
Linux kernel modules (LKMs) are pieces of code which can be loaded into the kernel much like a hot-swappable piece of hardware. they can be inserted into the kernel and activated without the system needing to be rebooted.

udev

The kernel is the central part of operating system to address the hardware. And to make sure that the hardware is available for the kernel udev plays an important role.
udev is a replacement for the Device File System (DevFS) starting with the Linux 2.6 kernel series. udev plays role in Loading Kernel Module, Creating Device Files and making sure every thing is the order we need it to be. Lets see how it works:
    1.
    The linux kernel initiates the device loading and next sends out messages (uevents) to the udev daemon.
    2.
    udev daemon catches the event and decide how to handle based on the attributes that it has received in the event. udev load required kernel module with necessary information using modprobe.
what is modprobe?
modprobe is an intelligent command for listing, inserting as well as removing modules from the kernel.( Will be explained )
3 . udev next reads its rules . udev allows us to ban devices based on their properties, like vendor ID and device ID, ... .
    Default rules are in /lib/udev/rules.d
    Cutom rules are in /etc/udev/rules.d
Lets see it in action, we use and then attach a usb storage:
1
[email protected]:~# udevadm monitor
2
monitor will print the received events for:
3
UDEV - the event which udev sends out after rule processing
4
KERNEL - the kernel uevent
5
6
KERNEL[12768.963188] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1 (usb)
7
KERNEL[12768.972503] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0 (usb)
8
UDEV [12769.092526] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1 (usb)
9
KERNEL[12769.206478] add /module/usb_storage (module)
10
UDEV [12769.218392] add /module/usb_storage (module)
11
KERNEL[12769.220850] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33 (scsi)
12
KERNEL[12769.221595] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/scsi_host/host33 (scsi_host)
13
KERNEL[12769.223741] add /bus/usb/drivers/usb-storage (drivers)
14
KERNEL[12769.225915] add /module/uas (module)
15
KERNEL[12769.227659] add /bus/usb/drivers/uas (drivers)
16
UDEV [12769.227861] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0 (usb)
17
UDEV [12769.244207] add /bus/usb/drivers/usb-storage (drivers)
18
UDEV [12769.246246] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33 (scsi)
19
UDEV [12769.247844] add /module/uas (module)
20
UDEV [12769.253961] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/scsi_host/host33 (scsi_host)
21
UDEV [12769.256450] add /bus/usb/drivers/uas (drivers)
22
KERNEL[12770.248662] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0 (scsi)
23
UDEV [12770.250053] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0 (scsi)
24
KERNEL[12770.251421] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0 (scsi)
25
KERNEL[12770.251639] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_disk/33:0:0:0 (scsi_disk)
26
KERNEL[12770.252615] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_device/33:0:0:0 (scsi_device)
27
UDEV [12770.253448] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0 (scsi)
28
KERNEL[12770.253478] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_generic/sg2 (scsi_generic)
29
KERNEL[12770.253663] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/bsg/33:0:0:0 (bsg)
30
UDEV [12770.256761] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_disk/33:0:0:0 (scsi_disk)
31
UDEV [12770.262849] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_device/33:0:0:0 (scsi_device)
32
UDEV [12770.263142] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/bsg/33:0:0:0 (bsg)
33
UDEV [12770.263288] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/scsi_generic/sg2 (scsi_generic)
34
KERNEL[12770.264594] add /devices/virtual/bdi/8:16 (bdi)
35
UDEV [12770.265053] add /devices/virtual/bdi/8:16 (bdi)
36
KERNEL[12770.287541] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb (block)
37
KERNEL[12770.288023] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb/sdb1 (block)
38
UDEV [12770.642686] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb (block)
39
UDEV [12770.829877] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb/sdb1 (block)
40
KERNEL[12771.061812] add /module/nls_iso8859_1 (module)
41
UDEV [12771.063716] add /module/nls_iso8859_1 (module)
Copied!
udev write device information to the /sys virtual directory. Also udev works as an Hardware Abstaraction Layer(HAL) and creates device file entries under /dev directory in a structured way.
What is HAL? In computers, a hardware abstraction layer (HAL) is a layer of programming that allows a computer OS to interact with a hardware device at a general or abstract level rather than at a detailed hardware level.
another example:
1
[email protected]:~# udevadm info --query=all --name=/dev/sdb
2
P: /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb
3
N: sdb
4
S: disk/by-id/usb-Kingston_DT_101_II_0013729982D5B97196320049-0:0
5
S: disk/by-path/pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0
6
E: DEVLINKS=/dev/disk/by-path/pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0 /dev/disk/by-id/usb-Kingston_DT_101_II_0013729982D5B97196320049-0:0
7
E: DEVNAME=/dev/sdb
8
E: DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host33/target33:0:0/33:0:0:0/block/sdb
9
E: DEVTYPE=disk
10
E: ID_BUS=usb
11
E: ID_INSTANCE=0:0
12
E: ID_MODEL=DT_101_II
13
E: ID_MODEL_ENC=DT\x20101\x20II\x20\x20\x20\x20\x20\x20\x20
14
E: ID_MODEL_ID=1625
15
E: ID_PART_TABLE_TYPE=dos
16
E: ID_PART_TABLE_UUID=de86c489
17
E: ID_PATH=pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0
18
E: ID_PATH_TAG=pci-0000_02_03_0-usb-0_1_1_0-scsi-0_0_0_0
19
E: ID_REVISION=PMAP
20
E: ID_SERIAL=Kingston_DT_101_II_0013729982D5B97196320049-0:0
21
E: ID_SERIAL_SHORT=0013729982D5B97196320049
22
E: ID_TYPE=disk
23
E: ID_USB_DRIVER=usb-storage
24
E: ID_USB_INTERFACES=:080650:
25
E: ID_USB_INTERFACE_NUM=00
26
E: ID_VENDOR=Kingston
27
E: ID_VENDOR_ENC=Kingston
28
E: ID_VENDOR_ID=0951
29
E: MAJOR=8
30
E: MINOR=16
31
E: SUBSYSTEM=block
32
E: TAGS=:systemd:
33
E: USEC_INITIALIZED=12770500291
Copied!
We have seen this information previously. Try udevadm info --attribute-walk --name=/dev/sda for your self. These device attributes can be used in udev rules.

/dev

This directory contains the device files for every hardware device attached to the system.
Device files are employed to provide the operating system and users an interface to the devices that they represent.
/dev exits from early beginning versions of linux and it was populated by devfs. (As we mentioned) devfs was a an obsolete and no longer available.
These days, it has been replaced by udev, a daemon that manages the contents of /dev in a temporary filesystem, (or by devtmpfs, which is a lightweight replacement for devfs that is used in some minimal systems).
1
[email protected]:~# ls /dev/
2
agpgart hwrng port tty10 tty33 tty56 ttyS2 vcs1
3
autofs initctl ppp tty11 tty34 tty57 ttyS20 vcs2
4
block input psaux tty12 tty35 tty58 ttyS21 vcs3
5
bsg kmsg ptmx tty13 tty36 tty59 ttyS22 vcs4
6
btrfs-control lightnvm pts tty14 tty37 tty6 ttyS23 vcs5
7
bus log random tty15 tty38 tty60 ttyS24 vcs6
8
cdrom loop0 rfkill tty16 tty39 tty61 ttyS25 vcs7
9
cdrw loop1 rtc tty17 tty4 tty62 ttyS26 vcsa
10
char loop2 rtc0 tty18 tty40 tty63 ttyS27 vcsa1
11
console loop3 sda tty19 tty41 tty7 ttyS28 vcsa2
12
core loop4 sda1 tty2 tty42 tty8 ttyS29 vcsa3
13
cpu_dma_latency loop5 sda2 tty20 tty43 tty9 ttyS3 vcsa4
14
cuse loop6 sda5 tty21 tty44 ttyprintk ttyS30 vcsa5
15
disk loop7 sg0 tty22 tty45 ttyS0 ttyS31 vcsa6
16
dmmidi loop-control sg1 tty23 tty46 ttyS1 ttyS4 vcsa7
17
dri mapper shm tty24 tty47 ttyS10 ttyS5 vfio
18
dvd mcelog snapshot tty25 tty48 ttyS11 ttyS6 vga_arbiter
19
ecryptfs mem snd tty26 tty49 ttyS12 ttyS7 vhci
20
fb0 memory_bandwidth sr0 tty27 tty5 ttyS13 ttyS8 vhost-net
21
fd midi stderr tty28 tty50 ttyS14 ttyS9 vmci
22
full mqueue stdin tty29 tty51 ttyS15 uhid vsock
23
fuse net stdout tty3 tty52 ttyS16 uinput zero
24
hidraw0 network_latency tty tty30 tty53 ttyS17 urandom
25
hpet network_throughput tty0 tty31 tty54 ttyS18 userio
26
hugepages null tty1 tty32 tty55 ttyS19 vcs
Copied!
Actually they are files and pointers to the under laying device hardware. Tryls -l to see that .
There are some common device names in .in linux World :
1
Name Device
2
cdrom CD drive
3
console Special entry for the currently used console.
4
cua* Serial ports
5
dsp* Devices for sampling and recording
6
fd* Entries for most kinds of floppy drives, the default is /dev/fd0, a floppy drive for 1.44 MB floppies.
7
hd[a-t][1-16] Standard support for IDE drives with maximum amount of partitions each.
8
ir* Infrared devices
9
isdn* Management of ISDN connections
10
js* Joystick(s)
11
lp* Printers
12
mem Memory
13
midi* midi player
14
mixer* and music Idealized model of a mixer (combines or adds signals)
15
modem Modem
16
mouse (also msmouse, logimouse, psmouse, input/mice, psaux) All kinds of mouses
17
null Bottomless garbage can
18
par* Entries for parallel port support
19
pty* Pseudo terminals
20
radio* For Radio Amateurs (HAMs).
21
ram* boot device
22
sd* SCSI disks with their partitions
23
sequencer For audio applications using the synthesizer features of the sound card (MIDI-device controller)
24
tty* Virtual consoles simulating vt100 terminals.
25
usb* USB card and scanner
26
video* For use with a graphics card supporting video.
Copied!
with the special thanks of udev (as a Hardware Abstraction Layer) and the names it provides.

/sys vs /dev

    The /sys filesystem (sysfs) contains files that provide information about devices: whether it's powered on, the vendor name and model, what bus the device is plugged into, etc. It's of interest to applications that manage devices.
    The /dev filesystem contains files that allow programs to access the devices themselves: write data to a serial port, read a hard disk, etc. It's of interest to applications that access devices.
A metaphor is that /sys provides access to the packaging, while /dev provides access to the content of the box.
The reason for /dev existing independently of /sys is partly historical: /dev dates back to the dawn of Unix, while /sys is a much more recent invention. If Linux was designed today with no historical background, /dev/sda might be /sys/block/sda/content.

pesudo File Systems

'Pseudo-' means false, pretend. So "pseudo-filesystem" means a filesystem that doesn't have actual files – rather, it has virtual entries that the filesystem itself makes up on the spot.
/dev, /proc and /sys are virtual "pseudo-filesystems" (not existing on harddisk, but only in RAM – so they do not consume any harddisk space and are completely created on boot).

dbus

D-Bus is a message bus system, a simple way for applications to talk to one another. Beside all of dbus benefits it can read information form /dev folder and relate them with user desktop programs using signals. In fact dbus make a kind of middle layer which keeps programs a way from difficulties of dealing with /dev and /sys directories.
Notice : udev and dbus can work in all distributions because sysfs has made required information standardize.
From the administrative perspective there are some ls utilities ( lsusb, lspci , ... ) to show more information about the hardware which has been attached to our system. Lets take a quick look at them:

lsusb

The lsusb command allows you to display information about USB buses and devices that are attached to them.
2
Bus 001 Device 002: ID 0951:1625 Kingston Technology DataTraveler 101 II
3
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
4
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
5
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
6
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Copied!
lsusb has some options:
1
[email protected]:~# lsusb --help
2
Usage: lsusb [options]...
3
List USB devices
4
-v, --verbose
5
Increase verbosity (show descriptors)
6
-s [[bus]:][devnum]
7
Show only devices with specified device and/or
8
bus numbers (in decimal)
9
-d vendor:[product]
10
Show only devices with the specified vendor and
11
product ID numbers (in hexadecimal)
12
-D device
13
Selects which device lsusb will examine
14
-t, --tree
15
Dump the physical USB device hierarchy as a tree
16
-V, --version
17
Show version of program
18
-h, --help
19
Show usage and help
Copied!
We can also use the -v command-line option to display more verbose output:
1
[email protected]:~# lsusb -v
2
3
[output truncated]
4
Bus 001 Device 002: ID 0951:1625 Kingston Technology DataTraveler 101 II
5
Device Descriptor:
6
bLength 18
7
bDescriptorType 1
8
bcdUSB 2.00
9
bDeviceClass 0 (Defined at Interface level)
10
bDeviceSubClass 0
11
bDeviceProtocol 0
12
bMaxPacketSize0 64
13
idVendor 0x0951 Kingston Technology
14
idProduct 0x1625 DataTraveler 101 II
15
bcdDevice 1.10
16
iManufacturer 1 Kingston
17
iProduct 2 DT 101 II
18
iSerial 3 0013729982D5B97196320049
19
bNumConfigurations 1
20
Configuration Descriptor:
21
bLength 9
22
bDescriptorType 2
23
wTotalLength 32
24
bNumInterfaces 1
25
bConfigurationValue 1
26
iConfiguration 0
27
bmAttributes 0x80
28
(Bus Powered)
29
MaxPower 300mA
30
[output truncated]
Copied!
-t tells lsusb to dump the physical USB device hierarchy as a tree. This overrides the v option.
1
[email protected]:~# lsusb -t
2
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
3
|__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
4
|__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/7p, 12M
5
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
6
|__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
Copied!
-Vor --version Print version information on standard output, then exit successfully.
1
[email protected]:~# lsusb -V
2
lsusb (usbutils) 007
Copied!
try usb-devices , it will give us more detailed info.

lscpu

lscpu reports information about the cpu and processing units. It does not have any further options or functionality.
2
Architecture: x86_64
3
CPU op-mode(s): 32-bit, 64-bit
4
Byte Order: Little Endian
5
CPU(s): 1
6
On-line CPU(s) list: 0
7
Thread(s) per core: 1
8
Core(s) per socket: 1
9
Socket(s): 1
10
NUMA node(s): 1
11
Vendor ID: GenuineIntel
12
CPU family: 6
13
Model: 142
14
Model name: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
15
Stepping: 9
16
CPU MHz: 2904.002
17
BogoMIPS: 5808.00
18
Hypervisor vendor: VMware
19
Virtualization type: full
20
L1d cache: 32K
21
L1i cache: 32K
22
L2 cache: 256K
23
L3 cache: 4096K
24
NUMA node0 CPU(s): 0
25
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
Copied!

lshw

lshw is a general purpose utility, that reports detailed and brief information about multiple different hardware units such as cpu, memory, disk, usb controllers, network adapters etc. Lshw extracts the information from different /proc files.
Do remember that the lshw command executed by root (superuser):
1
[email protected]:~# lshw --help
2
Hardware Lister (lshw) - B.02.17
3
usage: lshw [-format] [-options ...]
4
lshw -version
5
6
-version print program version (B.02.17)
7
8
format can be
9
-html output hardware tree as HTML
10
-xml output hardware tree as XML
11
-short output hardware paths
12
-businfo output bus information
13
14
options can be
15
-class CLASS only show a certain class of hardware
16
-C CLASS same as '-class CLASS'
17
-c CLASS same as '-class CLASS'
18
-disable TEST disable a test (like pci, isapnp, cpuid, etc. )
19
-enable TEST enable a test (like pci, isapnp, cpuid, etc. )
20
-quiet don't display status
21
-sanitize sanitize output (remove sensitive information like serial numbers, etc.)
22
-numeric output numeric IDs (for PCI, USB, etc.)
Copied!
Lets try lshw -short :
1
[email protected]:~# lshw -short
2
H/W path Device Class Description
3
========================================================
4
system VMware Virtual Platform
5
/0 bus 440BX Desktop Reference Platform
6
/0/0 memory 86KiB BIOS
7
/0/4 processor Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
8
/0/4/94 memory 16KiB L1 cache
9
/0/5 processor CPU
10
/0/5/95 memory 16KiB L1 cache
11
/0/6 processor CPU
12
/0/6/96 memory 16KiB L1 cache
13
/0/7 processor CPU
14
/0/7/97 memory 16KiB L1 cache
15
/0/8 processor CPU
16
/0/8/98 memory 16KiB L1 cache
17
/0/9 processor CPU
18
/0/9/99 memory 16KiB L1 cache
19
/0/a processor CPU
20
21
[output truncated]
Copied!

lspci

lspci is a utility for displaying information about PCI buses in the system and devices connected to them.By default, it shows a brief list of devices.
2
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
3
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
4
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
5
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
6
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
7
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
8
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
9
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
10
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
11
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
12
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
13
14
[output truncated]
15
16
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
17
02:00.0 USB controller: VMware USB1.1 UHCI Controller
18
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
19
02:02.0 Multimedia audio controller: Ensoniq ES1371 / Creative Labs CT2518/ES1373 (rev 02)
20
02:03.0 USB controller: VMware USB2 EHCI Controller
21
02:05.0 SATA controller: VMware SATA AHCI controller
Copied!
All of lspci switches:
1
[email protected]:~# lspci --help
2
lspci: invalid option -- '-'
3
Usage: lspci [<switches>]
4
5
Basic display modes:
6
-mm Produce machine-readable output (single -m for an obsolete format)
7
-t Show bus tree
8
9
Display options:
10
-v Be verbose (-vv for very verbose)
11
-k Show kernel drivers handling each device
12
-x Show hex-dump of the standard part of the config space
13
-xxx Show hex-dump of the whole config space (dangerous; root only)
14
-xxxx Show hex-dump of the 4096-byte extended config space (root only)
15
-b Bus-centric view (addresses and IRQ's as seen by the bus)
16
-D Always show domain numbers
17
18
Resolving of device ID's to names:
19
-n Show numeric ID's
20
-nn Show both textual and numeric ID's (names & numbers)
21
-q Query the PCI ID database for unknown ID's via DNS
22
-qq As above, but re-query locally cached entries
23
-Q Query the PCI ID database for all ID's via DNS
24
25
Selection of devices:
26
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] Show only devices in selected slots
27
-d [<vendor>]:[<device>][:<class>] Show only devices with specified ID's
28
29
Other options:
30
-i <file> Use specified ID database instead of /usr/share/misc/pci.ids.gz
31
-p <file> Look up kernel modules in a given file instead of default modules.pcimap
32
-M Enable `bus mapping' mode (dangerous; root only)
33
34
PCI access options:
35
-A <method> Use the specified PCI access method (see `-A help' for a list)
36
-O <par>=<val> Set PCI access parameter (see `-O help' for a list)
37
-G Enable PCI access debugging
38
-H <mode> Use direct hardware access (<mode> = 1 or 2)
39
-F <file> Read PCI configuration dump from a given file
Copied!
The -t option will display the output in tree format with information about bus, and how devices are connected to those buses. The output will be only using the numerical ids:
1
[email protected]:~# lspci -t
2
-[0000:00]-+-00.0
3
+-01.0-[01]--
4
+-07.0
5
+-07.1
6
+-07.3
7
+-07.7
8
+-0f.0
9
+-10.0
10
+-11.0-[02]--+-00.0
11
| +-01.0
12
| +-02.0
13
| +-03.0
14
| \-05.0
15
+-15.0-[03]--
16
+-15.1-[04]--
17
+-15.2-[05]--
18
+-15.3-[06]--
19
+-15.4-[07]--
20
+-15.5-[08]--
21
22
[output truncated]
23
24
+-18.3-[1e]--
25
+-18.4-[1f]--
26
+-18.5-[20]--
27
+-18.6-[21]--
28
\-18.7-[22]--
Copied!
lspci has a very helpful switch to know the name of the kernel module that will be handling the operations of a particular device. (this option will work only on Kernel 2.6 version and above):
1
[email protected]:~# lspci -k
2
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
3
Subsystem: VMware Virtual Machine Chipset
4
Kernel driver in use: agpgart-intel
5
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
6
Kernel modules: shpchp
7
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
8
Subsystem: VMware Virtual Machine Chipset
9
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
10
Subsystem: VMware Virtual Machine Chipset
11
Kernel driver in use: ata_piix
12
Kernel modules: pata_acpi
13
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
14
Subsystem: VMware Virtual Machine Chipset
15
Kernel modules: i2c_piix4
16
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
17
Subsystem: VMware Virtual Machine Communication Interface
18
Kernel driver in use: vmw_vmci
19
Kernel modules: vmw_vmci
20
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
21
Subsystem: VMware SVGA II Adapter
22
Kernel driver in use: vmwgfx
23
Kernel modules: vmwgfx
24
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
25
Subsystem: VMware LSI Logic Parallel SCSI Controller
26
Kernel driver in use: mptspi
27
Kernel modules: mptspi
28
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
29
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
30
Kernel driver in use: pcieport
31
Kernel modules: shpchp
32
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
33
Kernel driver in use: pcieport
34
Kernel modules: shpchp
35
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
36
Kernel driver in use: pcieport
37
Kernel modules: shpchp
38
39
[output truncated]
40
41
00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)
42
Kernel driver in use: pcieport
43
Kernel modules: shpchp
44
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
45
Kernel driver in use: pcieport
46
Kernel modules: shpchp
47
02:00.0 USB controller: VMware USB1.1 UHCI Controller
48
DeviceName: usb
49
Subsystem: VMware USB1.1 UHCI Controller
50
Kernel driver in use: uhci_hcd
51
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
52
DeviceName: Ethernet0
53
Subsystem: VMware PRO/1000 MT Single Port Adapter
54
Kernel driver in use: e1000
55
Kernel modules: e1000
56
02:02.0 Multimedia audio controller: Ensoniq ES1371 / Creative Labs CT2518/ES1373 (rev 02)
57
DeviceName: sound
58
Subsystem: Ensoniq AudioPCI 64V/128 / Creative CT4810/CT5803/CT5806 [Sound Blaster PCI]
59
Kernel driver in use: snd_ens1371
60
Kernel modules: snd_ens1371
61
02:03.0 USB controller: VMware USB2 EHCI Controller
62
DeviceName: ehci
63
Subsystem: VMware USB2 EHCI Controller
64
Kernel driver in use: ehci-pci
65
02:05.0 SATA controller: VMware SATA AHCI controller
66
DeviceName: sata0
67
Subsystem: VMware SATA AHCI controller
68
Kernel driver in use: ahci
69
Kernel modules: ahci
Copied!
lets try a tool in order to see whether these modules have been loaded.

lsmod

lsmod is a very simple program with no options.
1
[email protected]:~# lsmod --help
2
Usage: lsmod
Copied!
it nicely formats the contents of the file /proc/modules, which contains information about the status of all currently-loaded Linux Kernel Modules (LKMs).
2
Module Size Used by
3
nls_iso8859_1 16384 1
4
uas 24576 0
5
usb_storage 69632 2 uas
6
vmw_vsock_vmci_transport 28672 2
7
vsock 36864 3 vmw_vsock_vmci_transport
8
xt_multiport 16384 1
9
iptable_filter 16384 1
10
ip_tables 24576 1 iptable_filter
11
x_tables 36864 3 xt_multiport,ip_tables,iptable_filter
12
crct10dif_pclmul 16384 0
13
crc32_pclmul 16384 0
14
vmw_balloon 20480 0
15
ghash_clmulni_intel 16384 0
16
pcbc 16384 0
17
snd_ens1371 28672 2
18
snd_ac97_codec 131072 1 snd_ens1371
19
aesni_intel 167936 0
20
gameport 16384 1 snd_ens1371
21
ac97_bus 16384 1 snd_ac97_codec
22
aes_x86_64 20480 1 aesni_intel
23
crypto_simd 16384 1 aesni_intel
24
snd_pcm 102400 2 snd_ac97_codec,snd_ens1371
25
glue_helper 16384 1 aesni_intel
26
cryptd 24576 3 crypto_simd,ghash_clmulni_intel,aesni_intel
27
snd_seq_midi 16384 0
28
snd_seq_midi_event 16384 1 snd_seq_midi
29
input_leds 16384 0
30
snd_rawmidi 32768 2 snd_seq_midi,snd_ens1371
31
joydev 20480 0
32
serio_raw 16384 0
33
snd_seq 65536 2 snd_seq_midi_event,snd_seq_midi
34
snd_seq_device 16384 3 snd_seq,snd_rawmidi,snd_seq_midi
35
snd_timer 32768 2 snd_seq,snd_pcm
36
snd 77824 11 snd_seq,snd_ac97_codec,snd_timer,snd_rawmidi,snd_ens1371,snd_seq_device,snd_pcm
37
soundcore 16384 1 snd
38
nfit 49152 0
39
i2c_piix4 24576 0
40
shpchp 36864 0
41
vmw_vmci 69632 2 vmw_balloon,vmw_vsock_vmci_transport
42
mac_hid 16384 0
43
binfmt_misc 20480 1
44
parport_pc 32768 0
45
ppdev 20480 0
46
lp 20480 0
47
parport 49152 3 lp,parport_pc,ppdev
48
autofs4 40960 2
49
vmw_pvscsi 24576 0
50
vmxnet3 61440 0
51
hid_generic 16384 0
52
usbhid 53248 0
53
hid 118784 2 hid_generic,usbhid
54
vmwgfx 241664 4
55
ttm 98304 1 vmwgfx
56
psmouse 139264 0
57
drm_kms_helper 151552 1 vmwgfx
58
syscopyarea 16384 1 drm_kms_helper
59
sysfillrect 16384 1 drm_kms_helper
60
sysimgblt 16384 1 drm_kms_helper
61
fb_sys_fops 16384 1 drm_kms_helper
62
mptspi 24576 2
63
ahci 36864 0
64
libahci 32768 1 ahci
65
e1000 143360 0
66
drm 352256 7 vmwgfx,ttm,drm_kms_helper
67
mptscsih 40960 1 mptspi
68
mptbase 102400 2 mptscsih,mptspi
69
scsi_transport_spi 32768 1 mptspi
70
pata_acpi 16384 0
71
fjes 77824 0
Copied!
try cat /proc/modules and compare the results.
There is nothing like Drivers in linux and as we said, udev is responsible for calling related module with required information using modprobe.

modprobe

modprobe intelligently adds or removes a module from the Linux kernel. For demonstration lets remove and add e1000 module which is for Ethernet car on my system:
1
[email protected]:~# modprobe -r e1000
2
[email protected]:~# modprobe e1000
Copied!
and we would get disconnected and then connected again. modprobe has a long list of options trymodprobe --help to see them.
.
.
.
Sources:
Last modified 1yr ago