By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Key Topics: Communicating with Linux Devices Working with Devices Using Hot-Pluggable Devices
The typical Linux system has lots of different hardware devices connected to it. The list can include hard drives, monitors, keyboards, printers, audio cards, and network cards. Part of your job as a Linux administrator is to make sure all of those devices are working, and working properly. This guide walks you through how to install and troubleshoot the different types of hardware devices that can be connected to your Linux system.
First, we discuss the different types of device interfaces you may need to work with on your Linux system and how they communicate with the operating system. Following that, we discuss the Linux utilities available for you to monitor and troubleshoot how those devices on your system are working. Finally, we dive into the topic of hot-pluggable devices, a topic that has become extremely important with the popularity of USB devices. Communicating with Linux Devices For any device to work on your Linux system, the Linux kernel must recognize it and know how to talk to it. The kernel uses installed modules (read “Tending Kernel Modules”) to know how to communicate with each type of hardware device on the system. If the module for a particular hardware device isn't loaded, then the kernel won't be able to communicate with the device. After the kernel module is installed, the kernel must know how to communicate with the device. Linux supports several different types of hardware interfaces and methods for communicating with devices. Device Interfaces Each device you connect to your Linux system uses some type of standard protocol to communicate with the system hardware. The kernel module software must know how to send data to and receive data from the hardware device using those protocols. There are currently three popular standards used to connect devices. PCI Boards The Peripheral Component Interconnect (PCI) standard was developed in 1993 as a method for connecting hardware boards to PC motherboards. The standard has been updated a few times to accommodate faster interface speeds as well as increase data bus sizes on motherboards. The PCI Express (PCIe) standard is currently used on most server and desktop workstations to provide a common interface for external hardware cards. Lots of different client devices use PCI boards to connect to a server or desktop workstation: Internal Hard Drives- Hard drives using the Serial Advanced Technology Attachment (SATA) and the Small Computer System Interface (SCSI) connectors often use PCI boards to connect with workstations or servers. The Linux kernel automatically recognizes both SATA and SCSI hard drives connected to PCI boards. External Hard Drives- Network hard drives using the Fibre Channel standard provide a high-speed shared drive environment for server environments. To communicate on a Fibre Channel network, the server usually uses PCI boards that support the Host Bus Adapter (HBA) standard. Network Interface Cards- Hard-wired network cards allow you to connect the workstation or server to a local area network using the common RJ-45 cable standard. These types of connections are mostly found in high-speed network environments that require high throughput to the network. Wireless Cards- There are PCI boards available that support the IEEE 802.11 standard for wireless connections to local area networks. Although not commonly used in server environments, they are popular in workstation environments. Bluetooth Devices- The Bluetooth technology allows for short-distance wireless communication with other Bluetooth devices in a peer-to-peer network setup. They are most commonly found in workstation environments. Video Accelerators- Applications that require advanced graphics often use video accelerator cards, which offload the video processing requirements from the CPU to provide faster graphics. While these are popular in gaming environments, you'll also find video accelerator cards used in video processing applications for editing and processing movies, and in applications that require advanced mathematical operations, such as block chain generation. Audio Cards- Similarly, applications that require high-quality sound often use specialty audio cards to provide advanced audio processing and play, such as handling Dolby surround sound to enhance the audio quality of movies. The USB Interface The Universal Serial Bus (USB) interface has become increasingly popular due to its ease of use and its increasing support for high-speed data communication. Since the USB interface uses serial communications, it requires fewer connectors with the motherboard, allowing for smaller interface plugs. The USB standard has evolved over the years. The original version 1.0 only supported data transfer speeds up to 12 Mbps. The 2.0 standard increased the data transfer speed to 480 Mbps. The current USB standard, 4.0, allows for data transfer speeds up to 40 Gbps, making it useful for high-speed connections to external storage devices. A myriad of devices can connect to systems using the USB interface. You can find hard drives, printers, digital cameras and camcorders, keyboards, mice, and network cards that have versions that connect using the USB interface. Linux and USB devices There are two steps to get Linux to interact with USB devices.
The first step is that the Linux kernel must have the proper module installed to recognize the USB controller installed on your server, workstation, or laptops. The controller provides communication between the Linux kernel and the USB bus on the system. When the Linux kernel can communicate with the USB bus, any device you plug into a USB port on the system will be recognized by the kernel but is not necessarily usable.
The second step is that the Linux system must have a kernel module installed for the individual device type plugged into the USB bus. Linux distributions have a wide assortment of modules installed by default. Should you run into a USB device that doesn't work on your Linux system, refer to this guide or information on installing kernel modules. The GPIO Interface The general-purpose input/output (GPIO) interface has become popular with small utility Linux systems designed for controlling external devices for automation projects. This includes popular hobbyist Linux systems such as the Raspberry Pi and BeagleBone kits. The GPIO interface provides multiple digital input and output lines that you can control individually, down to the single-bit level. The GPIO function is normally handled by a specialty integrated circuit (IC) chip, which is mapped into memory on the Linux system. The GPIO interface is ideal for supporting communications to external devices such as relays, lights, sensors, and motors. Applications can read individual GPIO lines to determine the status of switches, turn relays on or off, or read digital values returned from any type of analog-to-digital sensors such as temperature or pressure sensors. With the GPIO interface, you have a wealth of possibilities for using Linux to control objects and environments. You can write programs that control the temperature in a room, sense when doors or windows are opened or closed, sense motion in a room, or even control the operation of a robot. The /dev Directory Once the Linux kernel can communicate with a device on an interface, it must be able to transfer data to and from the device. For many devices, this is done using device files. Device files are files that the Linux kernel creates in the special /dev directory to interface with hardware devices. To retrieve data from a specific device, a program just needs to read the Linux device file associated with that device. The Linux operating system handles all the unsightliness of interfacing with the actual hardware. Likewise, to send data to the device, the program just needs to write to the Linux device file. As you add hardware devices such as USB drives, network cards, or hard drives to your system, Linux creates a file in the /dev directory representing that hardware device. Application programs can then interact directly with that file to store and retrieve data on the device. This is much easier than requiring each application to know how to directly interact with a device.
There are two types of device files in Linux, based on how Linux transfers data to the device: Character device files: Transfer data one character at a time. This method is often used for serial devices such as terminals and USB devices. Block device files: Transfer large blocks of data. This method is often used for high-speed data transfer devices such as hard drives and network cards. The type of device file is denoted by the first letter in the permissions list, as shown below. List: Partial output from the /dev directory $ ls -al sd* tty* brw-rw---- 1 root disk 8, 0 Feb 16 17:49 sda brw-rw---- 1 root disk 8, 1 Feb 16 17:49 sda1 crw-rw-rw- 1 root tty 5, 0 Feb 16 17:49 tty crw--w---- 1 root tty 4, 0 Feb 16 17:49 tty0 crw--w---- 1 gdm tty 4, 1 Feb 16 17:49 tty1
The hard drive devices, sda and sda1, show the letter b, indicating that they are block device files. The tty terminal files show the letter c, indicating that they are character device files.
There are also a few special character device files that provide useful features for the shell. Ones of note are as follows: /dev/null: When data is redirected to this device, the data is discarded. This is handy for redirecting program messages that you don't want displayed. /dev/random and /dev/urandom: These devices files provide access to the kernel's random number generator. The /dev/random device blocks requests until enough random data has been generated to calculate a true random number. The /dev/urandom device doesn't block but just returns a random number using the random data currently available. Though less accurate, it's usually fine for most random number uses. /dev/zero: When data is read from this device, it returns a NULL character (0x00). This is an excellent resource for creating null files, or erasing previously stored data on a disk partition.
Besides device files, Linux also provides a system called the device mapper. The device mapper function is performed by the Linux kernel. It maps physical block devices to virtual block devices. These virtual block devices allow the system to intercept the data written to or read from the physical device and perform some type of operation on them. Mapped devices are used by the Logical Volume Manager (LVM) for creating logical drives and by the Linux Unified Key Setup (LUKS) for encrypting data on hard drives. Note: /dev/mapper directory. These files are links to the physical block device files in the /dev directory. The /proc Directory The /proc directory is one of the most important tools you can use when troubleshooting hardware issues on a Linux system. It's not a physical directory on the filesystem but instead a virtual directory that the kernel dynamically populates to provide access to information about the system hardware settings and status. The Linux kernel changes the files and data in the /proc directory as it monitors the status of hardware on the system. To view the status of the hardware devices and settings, you just need to read the contents of the virtual files using standard Linux text commands. There are different /proc files available for different system features, including the IRQs, I/O ports, and DMA channels in use on the system by hardware devices. The following sections discuss the files used to monitor these features and how you can access them. Interrupt Requests Interrupt requests (called IRQs) allow hardware devices to indicate when they have data to send to the CPU. The PnP system must assign each hardware device installed on the system a unique IRQ address. You can view the current IRQs in use on your Linux system by looking at the /proc/interrupts file using the Linux cat command, as shown below. List: List system interrupts from the /proc directory $ cat /proc/interrupts CPU0 0: 36 IO-APIC 2-edge timer 1: 297 IO-APIC 1-edge i8042 8: 0 IO-APIC 8-edge rtc0 9: 0 IO-APIC 9-fasteoi acpi 12: 396 IO-APIC 12-edge i8042 14: 0 IO-APIC 14-edge ata_piix 15: 914 IO-APIC 15-edge ata_piix 18: 2 IO-APIC 18-fasteoi vboxvideo 19: 4337 IO-APIC 19-fasteoi enp0s3
In the above list, the first column indicates the IRQ assigned to the device. Some IRQs are reserved by the system for specific hardware devices, such as 0 for the system timer and 1 for the system keyboard. Other IRQs are assigned by the system as devices are detected at boot time. I/O Ports The system I/O ports are locations in memory where the CPU can send data to and receive data from the hardware device. As with IRQs, the system must assign each device a unique I/O port. This is yet another feature handled by the PnP system. You can monitor the I/O ports assigned to the hardware devices on your system by looking at the /proc/ioports file, as shown below. List: Displaying the I/O ports on a system $ cat /proc/ioports 0000-0cf7 : PCI Bus 0000:00 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 0d00-ffff : PCI Bus 0000:00
There are lots of different I/O ports in use on the Linux system at any time, so your output will most likely differ from this example. With PnP, I/O port conflicts aren't very common, but it is possible that two devices are assigned the same I/O port. In that case, you can manually override the settings automatically assigned by using the setpci command. Direct Memory Access Using I/O ports to send data to the CPU can be somewhat slow. To speed things up, many devices use direct memory access (DMA) channels. DMA channels do what the name implies; they send data from a hardware device directly to memory on the system, without having to wait for the CPU. The CPU can then read those memory locations to access the data when it's ready. As with I/O ports, each hardware device that uses DMA must be assigned a unique channel number.
To view the DMA channels currently in use on the system, just display the /proc/dma file: $ cat /proc/dma 4: cascade This output indicates that only DMA channel 4 is in use on the Linux system. The /sys Directory Yet another tool available for working with devices is the /sys directory. The /sys directory is another virtual directory, similar to the /proc directory. It provides additional information about hardware devices that any user on the system can access. A number of information files are available within the /sys directory. They are broken down into subdirectories based on the device and function in the system. You can take a look at the subdirectories and files available within the /sys directory on your system by using the ls command-line command, as shown below. List: The contents of the /sys directory $ ls -al /sys dr-xr-xr-x 13 root root 0 Feb 16 18:06 . drwxr-xr-x 25 root root 4096 Feb 4 06:54 .. drwxr-xr-x 2 root root 0 Feb 16 17:48 block drwxr-xr-x 41 root root 0 Feb 16 17:48 bus drwxr-xr-x 62 root root 0 Feb 16 17:48 class drwxr-xr-x 4 root root 0 Feb 16 17:48 dev drwxr-xr-x 14 root root 0 Feb 16 17:48 devices drwxr-xr-x 5 root root 0 Feb 16 17:49 firmware drwxr-xr-x 8 root root 0 Feb 16 17:48 fs drwxr-xr-x 2 root root 0 Feb 16 18:06 hypervisor drwxr-xr-x 13 root root 0 Feb 16 17:48 kernel drwxr-xr-x 143 root root 0 Feb 16 17:48 module drwxr-xr-x 2 root root 0 Feb 16 17:48 power
Notice the different categories of information available. You can obtain information about the system bus, devices, kernel, and even kernel modules installed. Working with Devices Linux provides a wealth of command-line tools for using the devices connected to your system as well as monitoring and troubleshooting the devices if there are problems. The following sections walk through some of the popular tools you'll want to know about when working with Linux devices. Finding Devices One of the first tasks for a new Linux administrator is to find the different devices installed on the Linux system. Fortunately there are a few command-line tools to help out with that. The lsdev command The lsdev command-line command displays information about the hardware devices installed on the Linux system. It retrieves information from the /proc/interrupts, /proc/ioports, and /proc/dma virtual files and combines them in one output, as shown below. List: Output from the lsdev command $ lsdev Device DMA IRQ I/O Ports acpi 9 ACPI 4000-4003 4004-4005 4008-400b 4020-4021 ahci d240-d247 d248-d24b d250-d257 d258-d25b ata_piix 14 15 0170-0177 01f0-01f7 0376-0376 03f6-03f6 cascade 4 dma 0080-008f dma1 0000-001f dma2 00c0-00df e1000 d010-d017 enp0s3 19 fpu 00f0-00ff i8042 1 12 Intel d100-d1ff d200-d23f keyboard 0060-0060 0064-0064 ohci_hcd:usb1 22 PCI 0000-0cf7 0cf8-0cff 0d00-ffff pic1 0020-0021 pic2 00a0-00a1 piix4_smbus 4100-4108 rtc0 8 0070-0071 rtc_cmos 0070-0071 snd_intel8x0 21 timer 0 timer0 0040-0043 timer1 0050-0053 vboxguest 20 vboxvideo 18 vga+ 03c0-03df
This provides you with one place to view all the important information about the devices running on the system, making it easy to pick out any conflicts that can be causing problems. Note: lsdev tool is part of the procinfo package. You may need to manually install that package in some Linux distributions. The lsblk command The lsblk command-line command displays information about the block devices installed on the Linux system. By default, the lsblk command displays all of the block devices, as shown below. List: The output from the lsblk command $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 34.6M 1 loop /snap/gtk-common-themes/818 loop1 7:1 0 2.2M 1 loop /snap/gnome-calculator/222 sda 8:0 0 10G 0 disk sda1 8:1 0 10G 0 part ubuntu--vg-root 253:0 0 9G 0 lvm / ubuntu--vg-swap_1 253:1 0 976M 0 lvm [SWAP] sr0 11:0 1 1024M 0 rom
If you notice at the end of this list, the lsblk command also indicates blocks that are related, as with the device-mapped LVM volumes and the associated physical hard drive. You can modify the lsblk output to see additional information about the blocks by adding command-line options.
The -S option displays only information about SCSI block devices on the system: $ lsblk -S NAME HCTL TYPE VENDOR MODEL REV TRAN sda 2:0:0:0 disk ATA VBOX HARDDISK 1.0 sata sr0 1:0:0:0 rom VBOX CD-ROM 1.0 ata This is a quick way to view the different SCSI drives installed on the system. The dmesg command The kernel ring buffer records kernel-level events as they occur. Since it's a ring buffer, the event messages overwrite after the buffer area fills up. You can view the current messages in the kernel ring buffer by using the dmesg command. It helps to monitor it whenever you install a new device, as shown below. List: Partial output from the dmesg command [ 2525.499216] usb 1-2: new full-speed USB device number 3 using ohci-pci [ 2525.791093] usb 1-2: config 1 interface 0 altsetting 0 endpoint 0x1 has invalid maxpacket 512, setting to 64 [ 2525.791107] usb 1-2: config 1 interface 0 altsetting 0 endpoint 0x81 has [ 2525.821079] usb 1-2: New USB device found, idVendor=abcd, idProduct=1234 [ 2525.821088] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 2525.821094] usb 1-2: Product: UDisk [ 2525.821099] usb 1-2: Manufacturer: General ▭ [ 2525.821104] usb 1-2: SerialNumber: [ 2525.927096] usb-storage 1-2:1.0: USB Mass Storage device detected[ 2525.927096] usb-storage 1-2:1.0: USB Mass Storage device detected [ 2525.927950] scsi host3: usb-storage 1-2:1.0 [ 2525.928033] usbcore: registered new interface driver usb-storage [ 2525.940376] usbcore: registered new interface driver uas [ 2526.961754] scsi 3:0:0:0: Direct-Access General UDisk 5.00 PQ: 0 ANSI: 2 [ 2526.966646] sd 3:0:0:0: Attached scsi generic sg2 type 0 [ 2526.992707] sd 3:0:0:0: [sdb] 31336448 512-byte logical blocks: (16.0 GB/14.9 GiB) [ 2527.009197] sd 3:0:0:0: [sdb] Write Protect is off [ 2527.009200] sd 3:0:0:0: [sdb] Mode Sense: 0b 00 00 08 [ 2527.026764] sd 3:0:0:0: [sdb] No Caching mode page found [ 2527.026770] sd 3:0:0:0: [sdb] Assuming drive cache: write through [ 2527.127613] sdb: sdb1 [ 2527.229943] sd 3:0:0:0: [sdb] Attached SCSI removable disk
The output from the dmesg command shows the steps the kernel took to recognize the new USB device that was plugged into the system. Since the kernel is responsible for detecting devices and installing the correct modules, the dmesg command is a great troubleshooting tool to use when a device isn't working correctly. It can help you determine if a hardware device module didn't load correctly. Working with PCI Devices The lspci command allows you to view the currently installed and recognized PCI and PCIe devices on the Linux system. There are lots of command-line options you can include with the lspci command to display information about the PCI and PCIe cards installed on the system. TABLE: The lspci command-line options
The output from the lspci command without any options shows all devices connected to the system, as shown below. List: Using the lspci command $ 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) You can use the output from the lspci command to troubleshoot PCI card issues, such as if a card isn't recognized by the Linux system. Working with USB Devices You can view the basic information about USB devices connected to your Linux system by using the lsusb command. TABLE: The lsusb command options
The basic lsusb program output is shown below. List: The lsusb output $ lsusb Bus 001 Device 003: ID abcd:1234 Unknown Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Most systems incorporate a standard USB hub for connecting multiple USB devices to the USB controller. Fortunately, there are only a handful of USB hubs on the market, so all Linux distributions include the device drivers necessary to communicate with each of these USB hubs. That guarantees that your Linux system will at least detect when a USB device is connected. Supporting Monitors Two basic elements control the video environment on your Linux system: the video card and the monitor. To display any type of text or graphics, your Linux system must know how to interact with both of them. This is where the X Window System software comes in. The X Window System was developed at the Massachusetts Institute of Technology (MIT) to provide a standard protocol for interacting with displays. The X Window System is most commonly referred to as just X, or X11, since the last version defined is version 11.
The X11 system operates beneath the graphical desktop environment on your Linux system, as shown below.
Figure: The standard Linux graphics environment
The job of X11 is to interact with the hardware level of your system's video environment—the video card, monitor, keyboard, and mouse—and provide a standard interface that any desktop management software (such as KDE or GNOME) can use. Because of this, the X11 software must be able to interact with all of those hardware devices. The original X11 software for Linux was the XFree86 package. This was notorious for being difficult to configure and get working with different types of video hardware.
Because of that, newer X11 packages have surfaced and have become more common:
X.org: A user-friendly X11 software package for Linux, developed as a direct replacement for XFree86, but using simple text-based configuration files. It stores configuration files in a common /etc/X11 directory. Wayland: A simpler, more secure graphical software package, developed by Red Hat, and released as open source software. Wayland is becoming more popular with Linux distributions, quickly replacing even X.org. It stores separate configuration files for each user in the ~/.config/weston.ini file in each user's home directory.
Both the X.org and Wayland systems attempt to automatically detect the video card, monitor, keyboard, and mouse installed on the system at each boot time and dynamically change the configuration files accordingly. If you make any changes to the video card or monitor, they will automatically detect the new equipment and alter the configuration accordingly, making it a breeze to swap out new video equipment. X.org and Wayland packages include several different drivers that support common video cards and monitors. For both packages, however, if they don't recognize the specific video card or monitor on your system, they default to using generic drivers that may not produce the best-quality video experience. If your Linux system uses a specialty graphics card or monitor, it's best to obtain the Linux drivers for them and follow the documentation to manually install the updated drivers. Using Printers Just as with the video environment in Linux, printing in Linux can be somewhat complex. With different types of printers available, trying to install the correct printer drivers as well as using the correct printer protocol to communicate with them can be a nightmare.
Fortunately, the Common Unix Printing System (CUPS) solves many of those problems for us. CUPS provides a common interface for working with any type of printer on your Linux system. It accepts print jobs using the PostScript document format and sends them to printers using a print queue system. The print queue is a holding area for files sent to be printed. The print queue is normally configured to support not only a specific printer but also a specific printing format, such as landscape or portrait mode, single-sided or double-sided printing, or even color or black-and-white printing. There can be multiple print queues assigned to a single printer or multiple printers that can accept jobs assigned to a single print queue.
The CUPS software uses the Ghostscript program to convert the PostScript document into a format understood by the different printers. The Ghostscript program requires different drivers for the different printer types to know how to convert the document to make it printable on a certain type of printer. This is done using configuration files and drivers. Fortunately, CUPS installs many different drivers for common printers on the market and automatically sets the configuration requirements to use them. The configuration files are stored in the /etc/cups directory. To define a new printer on your Linux system you can use the CUPS web interface. Open your browser and navigate to the URL http://localhost:631. Figure below shows the web interface used by CUPS. Figure: The CUPS main web page
The CUPS web interface allows you to define new printers, modify existing printers, and check on the status of print jobs sent to each printer. Not only does CUPS recognize directly connected printers, but you can also configure network printers using several standard network printing protocols, such as the Internet Printing Protocol (IPP) or the Microsoft Server Message Block (SMB) protocol.
Aside from the CUPS web interface, there are a few command-line tools you can use for interacting with the print queues: lpc: Start, stop, or pause the print queue. lpq: Display the print queue status, along with any print jobs waiting in the queue. lpr: Submit a new print job to a print queue. lprm: Remove a specific print job from the print queue.
If you're working from the command line, you can check the status of any print queue as well as submit print jobs. For each of the commands, to specify the printer use the -P command-line option along with the printer name, as shown below. List: Printing from the command line in Linux $ lpq -P EPSON_ET_3750_Series EPSON_ET_3750_Series is ready no entries $ lpr -P EPSON_ET_3750_Series test.txt $ lpq -P EPSON_ET_3750_Series EPSON_ET_3750_Series is ready and printing Rank Owner Job File(s) Total Size active rich 1 test.txt 1024 bytes
The first line in this list uses the lpq command to check the status of the print queue, which shows that the printer is ready to accept new jobs and doesn't currently have any jobs in the print queue. The lpr command submits a new print job to print a file. After the new print job is submitted, the lpq command shows that the printer is currently printing and shows the print job that's being printed.
Tip: abrt) to create a report if any kernel-level hardware errors are detected. Red Hat Linux customers can send the report to tech support to help troubleshoot the hardware issue. Using Hot-Pluggable Devices Computer hardware is generally categorized into two types: Cold-pluggable devices Hot-pluggable devices
Cold-pluggable devices are hardware that can be connected to the system only when the system is completely powered down. These usually include things commonly found inside the computer case, such as memory, PCI cards, and hard drives. You can't remove any of these things while the system is running. Conversely, you can usually add and remove hot-pluggable devices at any time. They are often external components, such as network connections, monitors, and USB devices. The trick with hot-pluggable devices is that somehow the Linux kernel needs to know when the device is connected and automatically load the correct device driver module to support the device. Linux provides an entire subsystem that interacts with hot-pluggable devices, making them accessible to users. This subsystem is described in the following sections. Detecting Dynamic Devices The udev device manager is a program that is automatically started at boot time by the init process (usually at run level 5 via the /etc/rc5.d/udev script) or the systemd systems and runs in the background at all times. It listens to kernel notifications about hardware devices. As new hardware devices are plugged into the running system, or existing hardware devices removed, the kernel sends out notification event messages. The udev program listens to these notification messages and compares the messages against rules defined in a set of configuration files, normally stored under the /etc/udev/rules.d directory. If a device matches a defined rule, udev acts on the event notification as defined by the rule.
Each Linux distribution defines a standard set of rules for udev to follow. Rules define actions such as mounting USB memory sticks under the /media folder when they're installed or disabling network access when a USB network card is removed. You can modify the rules defined, but it's usually not necessary. Working with Dynamic Devices While the udev program runs in the background on your Linux system, you can still interact with it using the udevadm command-line tool. The udevadm command allows you to send commands to the udev program. The format of the udevadm command is as follows: udevadm command [options] TABLE: The udevadm commands
The control command allows you to change the currently running udev program. For example, by adding the -R option, you can force udev to reload the rules defined in the /etc/udev/rules.d directory. EXERCISE: Adding a USB Storage Device to the Linux System This exercise walks you through how to view the kernel messages and device entries that occur when you connect a USB storage device to the Linux system.
There are lots of ways to connect hardware devices to Linux systems. Both PCI and USB interfaces provide a standard way for connecting devices to the main motherboard so they can communicate. The newer GPIO interface provides a way to interact with smaller devices that use a single line for inputs and outputs that control sensors, switches, relays, and motors. Besides the physical interfaces, Linux also uses files to communicate with devices. When you connect a device to the system, Linux automatically creates a file in the /dev directory that's used for applications to send data to and receive data from the devices. The kernel uses the /proc directory to create virtual files that contain information about the devices and system status. The /sys directory is also used by the kernel to create files useful for troubleshooting device issues.
Linux provides a handful of command-line tools that you'll find useful when trying to troubleshoot device problems. The lsdev command allows you to view the status and settings for all devices on the system. The lsblk command provides information about block devices, such as hard drives and network cards, that are connected. The dmesg command lets you peek at the kernel ring buffer to view kernel event messages as it detects and works with devices. The lspci and lsusb commands allow you to view the PCI and USB devices that are connected to the Linux system. Linux also provides software to help with monitors and printers. The X11 protocol, used by the XFree86 and X.org software packages, detects and interfaces with the video card, monitor, keyboard, and mouse connected to the system, providing a standard interface for applications to use. The CUPS software provides a standard method for applications to send documents to both local and network printers.
Finally, this guide discussed how Linux handles hot-pluggable devices. The udev application monitors the kernel events for information about new hardware detected on USB ports. If a new device is detected, udev handles the device as defined in the rules set. The udevadm application allows you to control how udev works on your system. Important exam questions Describe how Linux systems communicate with devices. Linux systems create files in the /dev folder that applications use to send data to devices and retrieve data from devices. Device files can be either character files, which send and receive data one character at a time, or block files, which send and receive data in blocks. Explain how you would find the hardware settings for a PCI board plugged into the Linux system. The lspci command displays the PCI devices currently connected to the system. You can use that information with the lsdev command, which displays the interrupts, I/O ports, and DMA channels used by each device. You can also find that information in the /proc/interrupts, /proc/ioports, and /proc/dma files. Explain how Linux can detect hot-pluggable devices. The udev application runs in the background, monitoring the kernel ring buffer for new devices. When a new device is added, the udev application detects it from the kernel ring buffer messages and follows instructions defined in rules contained in the /etc/udev/rules.d directory.
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.