Determining and configuring hardware settings
How a Linux system finds out what hardware it has, and where that information lives: the kernel exposes devices through the /proc, /sys and /dev trees, udev creates the device nodes, and a handful of ls* commands read it back for you.
Lesson 1 of 3 in objective 101. System architecture, part of LPIC-1 Exam 101-500.
Three trees, three different jobs
/proc is the kernel talking about itself. It is a virtual filesystem — nothing in it is on a disk — holding one numbered directory per running process plus files describing the machine: /proc/cpuinfo, /proc/meminfo, /proc/interrupts, /proc/ioports, /proc/dma. Reading it is how tools like ps and free get their numbers.
/sys is newer, and it is the structured version of the same idea: one directory per device, arranged by the bus it hangs off, with the driver bound to it and the attributes it exposes. Where /proc grew organically and mixes everything together, sysfs is the tree udev and systemd actually walk.
/dev holds the device nodes — the special files a program opens to talk to a device. They are created at boot and on hotplug by udev, which watches kernel events, applies the rules in /etc/udev/rules.d and /lib/udev/rules.d, and can name a device predictably so that a USB disk gets the same path every time it is plugged in.
Modules are how the kernel gets a driver
Most drivers are not compiled into the kernel; they are loadable modules under /lib/modules/$(uname -r)/. lsmod lists what is loaded — it is a formatter for /proc/modules and takes no module argument — modprobe loads a module by name and pulls in whatever it depends on, and modprobe -r or rmmod unloads it. insmod loads a single file and resolves no dependencies at all, which is why it is almost never the right command.
Two more commands complete the set, and they are the two candidates most often meet for the first time in the exam room. modinfo reads the metadata compiled into the .ko file itself — description, author, licence, the modules it depends on, and one parm: line per parameter the driver accepts — so it works on a module that is not loaded and is how you find out which options a driver takes before setting them. depmod scans everything under /lib/modules/$(uname -r) and rebuilds modules.dep, the dependency map modprobe consults; you run it after installing a module by hand. The four divide cleanly: modinfo describes, lsmod lists, modprobe loads, depmod indexes.
Configuration for modules lives in /etc/modprobe.d/ — options passed to a driver, aliases, and blacklist lines that stop a module being loaded automatically. That last one is the usual fix when two drivers both claim a device, and usb_storage is the module most often blacklisted that way.
modinfo usb_storagefilename: /lib/modules/6.1.0-18/kernel/.../usb-storage.kolicense: GPLdescription: USB Mass Storage driver for Linuxdepends: usb-common,usbcoreparm: delay_use:seconds to delay (uint)Nothing was loaded — that came out of the filemodprobe usb_storagelsmod | grep usb_storageusb_storage 81920 0usbcore 348160 2 usb_storage,xhci_hcd
Reading and setting kernel tunables
A running kernel has several hundred settings that can be changed without rebooting, and they are exposed as files under /proc/sys. Reading one is cat; changing one is writing to it. sysctl is the front end for the same tree with dots in place of slashes, so /proc/sys/net/ipv4/ip_forward is net.ipv4.ip_forward to sysctl, and sysctl -a lists everything.
A write to /proc/sys lasts until the next reboot, because nothing in /proc is on a disk. To make a setting survive, put it in /etc/sysctl.conf or a file under /etc/sysctl.d/, which are read at boot; sysctl -p applies them again immediately. Turning a machine into a router — net.ipv4.ip_forward = 1 — is the example the exam reaches for every time.
cat /proc/sys/net/ipv4/ip_forward0sysctl net.ipv4.ip_forwardnet.ipv4.ip_forward = 0sysctl -w net.ipv4.ip_forward=1net.ipv4.ip_forward = 1Gone at the next reboot. To keep it:echo 'net.ipv4.ip_forward = 1' > /etc/sysctl.d/99-router.confsysctl -p /etc/sysctl.d/99-router.conf
Firmware, and what is below the operating system
Before Linux runs at all, the machine's own firmware has already decided which devices exist. Classic BIOS and modern UEFI both offer a setup screen where integrated peripherals — the onboard serial port, the audio chip, virtualization extensions — can be enabled or disabled, and a device switched off there is invisible to Linux no matter what you do afterwards. UEFI adds an EFI system partition, a FAT-formatted partition holding boot loaders, which is why /boot/efi appears in the mount table on modern installs.
One small thing worth knowing about where these tools live: the ls* inspection commands are ordinary user programs in /usr/bin — /usr/bin/lspci, /usr/bin/lsusb, /usr/bin/lsblk — while the ones that change kernel state live in /sbin or /usr/sbin, which is why /sbin/lsmod and /sbin/modprobe are the paths that turn up in a question about a command a normal user cannot run. lsblk, the block-device version of the same idea, lists disks and partitions as a tree.
Worth carrying in
- lspci
- Devices on the PCI bus. -v for detail, -k to show the kernel driver in use.
- lsusb
- Devices on the USB bus, with vendor and product ids.
- lsblk
- Block devices — disks, partitions and their mount points — as a tree.
- /sbin/lsmod
- Loaded kernel modules, their size, and what is using them. A formatter for
/proc/modules; it takes no module name. - modinfo
- Describes a module from the
.kofile, loaded or not: licence,depends, and the parameters it accepts. - modprobe
- Load a module by name, with dependencies.
-rremoves it. - depmod
- Rebuilds
modules.dep, the dependency mapmodprobereads. Run after installing a module by hand. - dmesg
- The kernel ring buffer: what the kernel said about the hardware as it found it.
- /proc/cpuinfo
- Per-core processor detail, including the flags that reveal virtualization support.
- /sys
- sysfs: one directory per device, by bus, with its driver and attributes.
- sysctl
- Read and write
/proc/sysby dotted name.-wsets for now,-pre-reads/etc/sysctl.confand/etc/sysctl.d/. - udevadm
- Query and control udev.
udevadm monitorshows events as devices appear.
What the exam does with this
- Know which tree answers which question:
/procfor kernel and process state,/sysfor the device model,/devfor the nodes you open. insmodversusmodprobeis a favourite:modproberesolves dependencies and searches the module directory,insmoddoes neither.- The four module verbs are asked as a set.
modinfodescribes without loading,lsmodlists what is loaded,modprobeloads,depmodindexes — andlsmod e1000is wrong becauselsmodtakes no argument. - A write to
/proc/sysis lost at reboot. Persisting it means/etc/sysctl.confor/etc/sysctl.d/, and that difference is the question. - D-Bus turns up here as the message bus that lets desktop and system services talk to each other about events like a disk being plugged in — it is not a kernel interface.
- Objective
- 101. System architecture
- Share of the exam
- 13.33% (the whole objective)
- Questions in this lesson
- 10
- Signed for by a person
- 0
Partly checked. None of the 10 questions here has been read against the cited source by a person. 10 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Determining and configuring hardware settings
Questions in this lesson
- You have a module file for a network driver on disk but the driver is not loaded. Which command reports the module's description, license, its dependencies and the parameters it accepts, without loading it into the kernel? machine-checked
- A module was loaded together with several modules it depends on. Which command unloads that module and then also unloads the dependencies that are left with a use count of zero? machine-checked
- You are filing a hardware bug report and the maintainer asks for the raw PCI vendor and device ID numbers rather than the human-readable names lspci normally prints. Which lspci option produces the numeric IDs? machine-checked
- A USB device is not getting the device node you expect. You want to watch, live, the kernel uevents and the resulting udev events as you unplug and replug it. Which command does that? machine-checked
- Which THREE of these statements about the /proc and /sys pseudo-filesystems are true? machine-checked
- Type the command, with no options or arguments, that lists the kernel modules currently loaded, one per line, with each module's size and use count. machine-checked
- Type the command, with no options, that lists the devices currently attached to the system's USB buses. machine-checked
- A network interface driver must always be loaded with the parameter InterruptThrottleRate=1, and the setting has to survive a reboot. Where do you record it? machine-checked
- A vendor asks you to confirm which interrupt line a capture card is using and how many interrupts it has taken since boot. Which file gives you both figures? machine-checked
- You have copied a new .ko module into /lib/modules/$(uname -r)/extra/ and modprobe still reports that the module is not found. Type the command, run as root, that rebuilds the module dependency database (modules.dep and its map files) for the running kernel. machine-checked
Practise Determining and configuring hardware settings
The rest of objective 101
- Determining and configuring hardware settings — you are here
- Booting the system
- Boot targets, shutting down and rebooting