There are many reasons you might need to find out details about your computer hardware. For example, if you need help fixing something and post a plea in an online forum, people will immediately ask you for specifics about your computer. Or, if you want to upgrade your computer, you'll need to know what you have and what you can have. You need to interrogate your computer to discover its specifications.
Sometimes it's easy to find a specific bit of information through a well-targeted line command. Perhaps you don't have a GUI program available or don't want to install one.
Probably the main reason to use line commands is for writing scripts. Whether you employ the Linux shell or another programming language, scripting typically requires coding line commands.
Many line commands for detecting hardware must be issued under root authority. So either switch to the root user ID, or issue the command under your regular user ID preceded by sudo:
and respond to the prompt for the root password.
This article introduces many of the most useful line commands for system discovery. The quick reference chart at the end summarizes them.
There are several line commands that will give you a comprehensive overview of your computer's hardware.
The inxi command lists details about your system, CPU, graphics, audio, networking, drives, partitions, sensors, and more. Forum participants often ask for its output when they're trying to help others solve problems. It's a standard diagnostic for problem-solving:
The -F flag means you'll get full output, x adds details, and z masks out personally identifying information like MAC and IP addresses.
The hwinfo and lshw commands display much of the same information in different formats:
The long forms of these two commands spew out exhaustive "but hard to read" output:
You can learn everything about your CPU through line commands. View CPU details by issuing either the lscpu command or its close relative lshw:
lshw -C cpu
In both cases, the last few lines of output list all the CPU's capabilities. Here you can find out whether your processor supports specific features.
With all these commands, you can reduce verbiage and narrow any answer down to a single detail by parsing the command output with the grep command. For example, to view only the CPU make and model:
lshw -C cpu | grep -i product
To view just the CPU's speed in megahertz:
lscpu | grep -i mhz
or its BogoMips power rating:
lscpu | grep -i bogo
The -i flag on the grep command simply ensures your search ignores whether the output it searches is upper or lower case.
Linux line commands enable you to gather all possible details about your computer's memory. You can even determine whether you can add extra memory to the computer without opening up the box.
To list each memory stick and its capacity, issue the dmidecode command:
dmidecode -t memory | grep -i size
For more specifics on system memory, including type, size, speed, and voltage of each RAM stick, try:
lshw -short -C memory
One thing you'll surely want to know is is the maximum memory you can install on your computer:
dmidecode -t memory | grep -i max
Now find out whether there are any open slots to insert additional memory sticks. You can do this without opening your computer by issuing this command:
lshw -short -C memory | grep -i empty
A null response means all the memory slots are already in use.
Determining how much video memory you have requires a pair of commands. First, list all devices with the lspci command and limit the output displayed to the video device you're interested in:
lspci | grep -i vga
The output line that identifies the video controller will typically look something like this:
Now reissue the lspci command, referencing the video device number as the selected device:
lspci -v -s 00:02.0
The output line identified as prefetchable is the amount of video RAM on your system:
Finally, to show current memory use in megabytes, issue:
This tells how much memory is free, how much is in use, the size of the swap area, and whether it's being used. For example, the output might look like this:
The top command gives you more detail on memory use. It shows current overall memory and CPU use and also breaks it down by process ID, user ID, and the commands being run. It displays full-screen text output:
Disks, filesystems, and devices
You can easily determine whatever you wish to know about disks, partitions, filesystems, and other devices.
To display a single line describing each disk device:
lshw -short -C disk
Get details on any specific SATA disk, such as its model and serial numbers, supported modes, sector count, and more with:
hdparm -i /dev/sda
Of course, you should replace sda with sdb or another device mnemonic if necessary.
To list all disks with all their defined partitions, along with the size of each, issue:
For more detail, including the number of sectors, size, filesystem ID and type, and partition starting and ending sectors:
To start up Linux, you need to identify mountable partitions to the GRUB bootloader. You can find this information with the blkid command. It lists each partition's unique identifier (UUID) and its filesystem type (e.g., ext3 or ext4):
To list the mounted filesystems, their mount points, and the space used and available for each (in megabytes):
Finally, you can list details for all USB and PCI buses and devices with these commands:
Linux offers tons of networking line commands. Here are just a few.
To see hardware details about your network card, issue:
lshw -C network
Traditionally, the command to show network interfaces was ifconfig:
But many people now use:
ip link show
In reading the output, it helps to know common network abbreviations:
|pppO||Point-to-Point Protocol interface (used by a dial-up modem, PPTP VPN connection, or USB modem)|
|vboxnetO or vmnet||Virtual machine interface|
The asterisks in this table are wildcard characters, serving as a placeholder for whatever series of characters appear from system to system.
To show your default gateway and routing tables, issue either of these commands:
ip route | column -t
Let's conclude with two commands that display low-level software details. For example, what if you want to know whether you have the latest firmware installed? This command shows the UEFI or BIOS date and version:
dmidecode -t bios
What is the kernel version, and is it 64-bit? And what is the network hostname? To find out, issue:
About the author: Howard Fosdick is an independent consultant who works hands-on as a DBA/SA. He's written several technical books, many articles, and is a popular conference speaker.
Opensource.com aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. Red Hat and the Red Hat logo are trademarks of Red Hat, Inc., registered in the United States and other countries.
Learn more at amazon.com