What's in the Box? Interrogate Your Linux Machine's Hardware
I recently had a problem trying to install the NVIDIA driver for my machine. It seemed the latest driver had stopped supporting my graphics card, and after updating my kernel, I was out of a driver. The question, obviously, was "which card did I have?" But, I didn't remember. If you have to name the chipset of your motherboard, specify the CPU in your box or get any other kind of hardware-related information, Linux provides several utilities to help you. In my case, I quickly could get the full ID of my graphics card, confirm that it really was getting a bit long in the tooth and decide that a newer one wasn't such a bad idea.
In this article, I discuss several ways of getting hardware data for your machine. In the most time-honored Linux shell way, I show how to work with several command-line utilities, but if you prefer using a GUI, I also include some graphical programs. And, if you want to get into the nitty-gritty details, I give some pointers on how to get that information by using the /proc or /sys filesystem.
Working with hardware means dealing with several acronyms, and I must admit, I had been using at least a couple of them without remembering precisely what they meant. Here's a list of definitions you'll surely need:
ACPI (Advanced Configuration and Power Interface): related to power aspects.
AGP (Accelerated Graphics Port): a channel to allow attaching a video graphics card (not typically seen since around 2008).
APM (Advanced Power Management): older than ACPI, also related to power issues.
ATA (AT Attachment): "AT", as in the old IBM AT, a standard to connect storage devices, superseded by SATA in 2003.
BIOS (Basic Input/Output System): firmware used when booting an Intel-compatible PC.
DMA (Direct Memory Access): a feature that allows giving hardware access to RAM, independently of the CPU.
DMI (Desktop Management Interface): a framework for keeping track of devices in a computer.
IDE (Integrated Drive Electronics): an interface standard that later evolved into ATA.
IRQ (Interrupt ReQuest): a hardware signal that allows an interrupt handler to process a given event.
PCI (Peripheral Component Interconnect): a bus standard for attaching varied hardware devices to a computer, created in 1992.
UEFI (Unified EFI—Extensible Firmware Interface): a 2005 replacement for BIOS, which deprecated the previous 1998 EFI standard.
USB (Universal Serial Bus): a standard bus defined in 1995 to allow connecting all kinds of peripherals to a computer.
PATA (Parallel ATA): the new name for ATA, after SATA came out.
PCIe (PCI Express): a high-speed serial bus that replaced PCI and AGP in 2004.
RAID (Redundant Array of Independent—originally, "Inexpensive"—Disks): a data storage virtualization technology that combines several drives to work as a single one for performance improvement and/or data redundancy. There are several RAID schemes, including RAID 0 ("striping"), RAID 1 ("mirroring"), RAID 5 ("striping + parity") and RAID 10 ("striping + mirroring").
SATA (Serial ATA): a bus interface to connect storage devices, currently used in practically all PCs.
SCSI (Small Computer System Interface—pronounced "scuzzy"): a set of standards for connection of devices and transfer of data between computers and peripherals.
ls Command Family
Let's start the command-line work with a set of several utilities,
whose names all start with
ls (Table 1). Some of
these commands provide overlapping information
for instance), but by using all of them, you can get a pretty clear idea
of whatever may be inside your Linux box.
||Produces information about all block devices, such as hard disks, DVD readers and more.|
||Shows information like number of CPUs, cores, threads and more.|
||Displays data about all devices of which the system is aware.|
||Lists general hardware data—gives information on every detail of your hardware.|
||Displays information about PCI buses in your box and devices connected to them, such as graphics cards, network adapters and more.|
||Provides information on all SCSI devices or hosts attached to your box, such as hard disk drives or optical drives.|
||Generates information about USB buses in your box and devices connected to them.|
Let's start with CPU information. The
lscpu command provides data on
the CPUs in your box. You can opt to include all CPUs, whether off-line
or on-line, with the
-.all parameter, or you can select
lets you choose what CPU
characteristics to list, including number, socket, cache data, maximum
and minimum speed (in MHz) and more. In my case, you'll see
that my machine has a somewhat old single-socket, four-core, Intel
Core 2 Quad CPU, at 2.66GHz:
> lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 23 Model name: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz Stepping: 10 CPU MHz: 2003.000 CPU max MHz: 2670.0000 CPU min MHz: 2003.0000 BogoMIPS: 5340.67 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 2048K NUMA node0 CPU(s): 0-3
(Note: you can get most of this information by examining the /proc/cpuinfo file or by browsing the /sys/bus/cpu/ directories; see the DIY with /proc and /sys sidebar for more on this.)
Let's move on to block devices, such as hard disks, or CD and DVD
lsblk command produces information on all available block
devices (see Listing 1 for an example). As you can see, I have three hard
disks and a ROM (DVD) device. The three disks are known as /dev/sda,
/dev/sdb and /dev/sdc; the ROM device is /dev/sr0. The disks are
466GB, 149GB and 2.7TB in size. You can get a little information about
partitioning too; for instance, you can see that the first two disks
have a swap area enabled, but the third one doesn't. You also can get
the mountpoints (/, /disk-laptop and /disk-data) for the three disks.
Listing 1. The
lsblk command shows all block (storage) devices. The
--topology option adds extra details; try
--output-all for even
> lsblk --paths NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT /dev/sda 8:0 0 465.8G 0 disk |__/dev/sda1 8:1 0 4G 0 part [SWAP] |__/dev/sda2 8:2 0 461.8G 0 part / /dev/sdb 8:16 0 149.1G 0 disk |__/dev/sdb1 8:17 0 4G 0 part [SWAP] |__/dev/sdb2 8:18 0 145G 0 part /disk-laptop /dev/sdc 8:32 0 2.7T 0 disk |__/dev/sdc1 8:33 0 2.7T 0 part /disk-data /dev/sr0 11:0 1 1024M 0 rom > lsblk --paths --topology NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE RA WSAME sda 0 512 0 512 512 1 cfq 128 128 0B |__sda1 0 512 0 512 512 1 cfq 128 128 0B |__sda2 0 512 0 512 512 1 cfq 128 128 0B sdb 0 512 0 512 512 1 cfq 128 128 0B |__sdb1 0 512 0 512 512 1 cfq 128 128 0B |__sdb2 0 512 0 512 512 1 cfq 128 128 0B sdc 0 4096 0 4096 512 1 cfq 128 128 0B |__sdc1 0 4096 0 4096 512 1 cfq 128 128 0B sr0 0 512 0 512 512 1 cfq 128 128 0B
There are many possible optional arguments, but the most typically used are
--paths, which produces full device paths, and
if you are interested in internal details, such as physical sector size,
I/O scheduler name and so on. You can get owner, group and permissions
--perm, as shown below (and, if you
really want detailed
--output-all, which will list about
50 columns' worth of data):
> lsblk --perm NAME SIZE OWNER GROUP MODE sda 465.8G root disk brw-rw---- |__sda1 4G root disk brw-rw---- |__sda2 461.8G root disk brw-rw---- sdb 149.1G root disk brw-rw---- |__sdb1 4G root disk brw-rw---- |__sdb2 145G root disk brw-rw---- sdc 2.7T root disk brw-rw---- |__sdc1 2.7T root disk brw-rw---- sr0 1024M root cdrom brw-rw----
For SCSI devices, you can add
lsblk, but there's
also the more specific
lsscsi command. The basic
information it produces is shown below, and it includes all available SCSI
In my case, it shows the three hard disks and the optical reader I already
lsblk, plus three card readers. Note that you also get
more information on specific brands and models. For example, I have two
Western Digital hard drives (WD5000AAKS and WD30EZRX), plus a Maxtor
laptop drive (STM316021) and a Sony AD-7200S DVD unit:
> lsscsi [2:0:0:0] disk ATA WDC WD5000AAKS-0 1D05 /dev/sda [2:0:1:0] disk ATA MAXTOR STM316021 D /dev/sdb [3:0:0:0] disk ATA WDC WD30EZRX-00M 0A80 /dev/sdc [3:0:1:0] cd/dvd SONY DVD RW AD-7200S 1.61 /dev/sr0 [4:0:0:0] disk Sony Card_R/W -CF 1.11 /dev/sdd [4:0:0:1] disk Sony Card_R/W -SD 1.11 /dev/sde [4:0:0:2] disk Sony Card_R/W -MS 1.11 /dev/sdf
Check out all the possibilities of this command with
You'll see that you really can dig down into SCSI devices with
it. And, if you're interested, this command works by scanning the /sys
filesystem (see Resources, and the DIY with /proc and /sys
sidebar for more information).
Now, let's move on to some other commands.
information on all USB-connected devices; see Listing 2 for an example. (An
usb-devices, but it's somewhat more obscure
in its output and has no configuration options.) As in most modern
computers, you'll probably have a lot of such devices. In my case, I
have a Bluetooth dongle, Webcam, keyboard, mouse and more. You
can get information on a specific bus or device with the
option or select a given vendor with the
-d option; for the latter, check the USB ID repository (see Resources) for
vendor/device numbers. Finally, if you want very detailed information,
-v (verbose) option, but be prepared to
read a lot.
For my machine,
lsusb -v produces more than 1,300
lines of output.
Listing 2. The
lsusb command reports all USB-connected devices, as a list
or in tree form.
> lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation ↪2.0 root hub Bus 005 Device 002: ID 054c:01bd Sony Corp. MRW62E ↪Multi-Card Reader/Writer Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 ↪root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 ↪root hub Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon ↪Radio, Ltd Bluetooth Dongle (HCI mode) Bus 003 Device 006: ID 1e4e:0100 Cubeternet WebCam Bus 003 Device 005: ID 046d:c317 Logitech, Inc. ↪Wave Corded Keyboard Bus 003 Device 004: ID 04f3:0232 Elan ↪Microelectronics Corp. Mouse Bus 003 Device 003: ID 05e3:0608 Genesys Logic, ↪Inc. Hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation ↪1.1 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation ↪1.1 root hub > lsusb --tree /: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M |__ Port 2: Dev 2, If 0, Class=Mass Storage, ↪Driver=usb-storage, 12M /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/4p, 12M |__ Port 1: Dev 4, If 0, Class=Human Interface Device, ↪Driver=usbhid, 1.5M |__ Port 2: Dev 5, If 0, Class=Human Interface Device, ↪Driver=usbhid, 1.5M |__ Port 2: Dev 5, If 1, Class=Human Interface Device, ↪Driver=usbhid, 1.5M |__ Port 3: Dev 6, If 0, Class=Video, Driver=uvcvideo, 12M |__ Port 3: Dev 6, If 1, Class=Video, Driver=uvcvideo, 12M |__ Port 2: Dev 2, If 0, Class=Wireless, Driver=btusb, 12M |__ Port 2: Dev 2, If 1, Class=Wireless, Driver=btusb, 12M /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
Another command that can produce a ton of
lspci, which shows all data on PCI devices. And,
as a matter of fact, this is the actual command I used to remember what
kind of graphics card I had:
# lspci 00:00.0 Host bridge: Intel Corporation 4 Series ↪Chipset DRAM Controller (rev 03) 00:01.0 PCI bridge: Intel Corporation 4 Series ↪Chipset PCI Express Root Port (rev 03) 00:1b.0 Audio device: Intel Corporation NM10/ICH7 ↪Family High Definition Audio Controller (rev 01) 00:1c.0 PCI bridge: Intel Corporation NM10/ICH7 ↪Family PCI Express Port 1 (rev 01) 00:1c.1 PCI bridge: Intel Corporation NM10/ICH7 ↪Family PCI Express Port 2 (rev 01) 00:1d.0 USB controller: Intel Corporation NM10/ICH7 ↪Family USB UHCI Controller #1 (rev 01) 00:1d.1 USB controller: Intel Corporation NM10/ICH7 ↪Family USB UHCI Controller #2 (rev 01) 00:1d.2 USB controller: Intel Corporation NM10/ICH7 ↪Family USB UHCI Controller #3 (rev 01) 00:1d.3 USB controller: Intel Corporation NM10/ICH7 ↪Family USB UHCI Controller #4 (rev 01) 00:1d.7 USB controller: Intel Corporation NM10/ICH7 ↪Family USB2 EHCI Controller (rev 01) 00:1e.0 PCI bridge: Intel Corporation 82801 PCI ↪Bridge (rev e1) 00:1f.0 ISA bridge: Intel Corporation 82801GB/GR ↪(ICH7 Family) LPC Interface Bridge (rev 01) 00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 ↪Family) IDE Controller (rev 01) 00:1f.2 IDE interface: Intel Corporation NM10/ICH7 ↪Family SATA Controller [IDE mode] (rev 01) 00:1f.3 SMBus: Intel Corporation NM10/ICH7 Family ↪SMBus Controller (rev 01) 01:00.0 Ethernet controller: Qualcomm Atheros AR8152 ↪v2.0 Fast Ethernet (rev c1) 04:00.0 VGA compatible controller: NVIDIA Corporation ↪GK107 [GeForce GT 740] (rev a1) 04:00.1 Audio device: NVIDIA Corporation GK107 HDMI ↪Audio Controller (rev a1)
-vv options, for verbose and very verbose
listings. To get full information on my (current) graphics card, I
proceeded as shown in Listing 3. I now have an NVIDIA GeForce 740, and I'm using
the nouveau kernel driver, among other internal details. Of course,
to understand the produced information fully, you must have a bit of
experience with PCI devices. Try the same command with
you'll see what I'm talking about.
Listing 3. The
-v option provides more detailed
# lspci -v -s 4:00.0 04:00.0 VGA compatible controller: NVIDIA Corporation ↪GK107 [GeForce GT 740] (rev a1) ↪(prog-if 00 [VGA controller]) Subsystem: eVga.com. Corp. Device 2742 Flags: bus master, fast devsel, latency 0, IRQ 27 Memory at fd000000 (32-bit, non-prefetchable) [size=16M] Memory at e0000000 (64-bit, prefetchable) [size=256M] Memory at de000000 (64-bit, prefetchable) [size=32M] I/O ports at ec00 [size=128] [virtual] Expansion ROM at fe000000 [disabled] [size=512K] Capabilities:  Power Management version 3 Capabilities:  MSI: Enable+ Count=1/1 Maskable- 64bit+ Capabilities:  Express Endpoint, MSI 00 Capabilities: [b4] Vendor Specific Information: Len=14 Capabilities:  Virtual Channel Capabilities:  Power Budgeting Capabilities:  Vendor Specific Information: ID=0001 ↪Rev=1 Len=024 Capabilities:  #19 Kernel driver in use: nouveau Kernel modules: nouveau
If you are even more electronically/digitally minded,
produces information about your installed hardware, including interrupts,
ports, addresses and all such internal details. This command provides no
options, and it's not likely you'll use it unless you are dealing very
closely with hardware. Listing 4 shows an abbreviated example of
the output. This command scans /proc/interrupts, /proc/ioports
and /proc/dma, as described in the DIY with /proc and /sys
- Android Browser Security--What You Haven't Been Told
- Epiq Solutions' Sidekiq M.2
- Readers' Choice Awards 2013
- Nativ Disc
- The Many Paths to a Solution
- Synopsys' Coverity
- Securing the Programmer
- RPi-Powered pi-topCEED Makes the Case as a Low-Cost Modular Learning Desktop
- Identity: Our Last Stand
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide