Skip to main content

7 Linux commands to gather information about your system

Get information about your CPU, storage, RAM, BIOS, and more without leaving the terminal.
Command line output in the terminal

Image by joffi from Pixabay

There are many situations when you need to obtain information about your Linux system, whether it's hardware, embedded software such as the BIOS, or how they relate to the operating system.

[ Learn how to manage your Linux environment for success. ]

You need this information to understand your system better, install appropriate software and drivers, apply patches, obtain vendor support, plan expansions and upgrades, and use your system fully.

In general, Linux distributions provide many tools you can use to display system information. Often, you can query one of the virtual filesystems like /proc or /sys directly, but they may provide basic information that's hard to understand at a glance.

This article looks at seven commands that provide details about your system's CPU, disk, RAM, devices, and firmware, in a direct and easy-to-understand way. These utilities compile information from different sources to present a relevant summary that aids you in understanding the system's capabilities.

I'll start by looking at the CPU.

Display CPU information

The lscpu utility provides a comprehensive summary of your CPU's capabilities, including model information, the number of cores, speeds, flags, virtualization capabilities, and security mitigations applied.

$ lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         48 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  2
  On-line CPU(s) list:   0,1
Vendor ID:               AuthenticAMD
  Model name:            AMD Ryzen 7 PRO 5850U with Radeon Graphics
    CPU family:          25
    Model:               80
    Thread(s) per core:  1
    Core(s) per socket:  1
    Socket(s):           2
    Stepping:            0
    BogoMIPS:            3792.88
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nop
                         l cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor l
                         ahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core ssbd ibrs ibpb stibp vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2
                          erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr wbnoinvd arat npt lbrv nrip_save tsc_scale vmcb_clean
                          pausefilter pfthreshold v_vmsave_vmload vgif umip pku ospke vaes vpclmulqdq rdpid fsrm arch_capabilities
Virtualization features:
  Virtualization:        AMD-V
  Hypervisor vendor:     KVM
  Virtualization type:   full

You can also use lscpu with the -p option to print specific fields only or -J for JSON output. Both of these options are great to parse with other programs or scripts.

Next, I'll look at the storage.

[ Cheat sheet: Get a list of Linux utilities and commands for managing servers and networks. ]

Gather disk information

Linux provides many utilities to look at the storage and disks attached to your system, such as df, fdisk, or mount. These are great options for gathering specific information. You can also use lsblk to get an overview of your block devices at a glance:

$ lsblk
sr0     11:0    1 1024M  0 rom
zram0  251:0    0  3.8G  0 disk [SWAP]
vda    252:0    0   32G  0 disk
├─vda1 252:1    0  600M  0 part /boot/efi
├─vda2 252:2    0    1G  0 part /boot
└─vda3 252:3    0 30.4G  0 part /home

This utility provides much more information, and you should check all of its options using man lsblk. I often use two options: --fs to include the filesystem type in the output and -J for JSON output to parse using other programs.

Show USB information

Use the lsusb utility to gather information about available USB devices. Your distribution may not include this utility by default. Install the usbutils package to access it:

$ sudo dnf install -y usbutils

Then use lsusb to see a list of USB devices:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

For a more detailed output, use the -v or -t option to format the output as a tree hierarchy.

Display PCI information

Next on the list is lspci to get information about your PCI devices. This utility is part of the pciutils package, and you may need to install it, depending on your distribution:

$ sudo dnf install -y pciutils

Run lspci for a summary of all attached PCI devices:

$ lspci
00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller
00:01.0 VGA compatible controller: Red Hat, Inc. Virtio GPU (rev 01)
00:02.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:02.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 03)
00:1f.0 ISA bridge: Intel Corporation 82801IB (ICH9) LPC Interface Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
01:00.0 Ethernet controller: Red Hat, Inc. Virtio network device (rev 01)
02:00.0 Ethernet controller: Red Hat, Inc. Virtio network device (rev 01)
03:00.0 USB controller: Red Hat, Inc. QEMU XHCI Host Controller (rev 01)
04:00.0 Communication controller: Red Hat, Inc. Virtio console (rev 01)
05:00.0 SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)
06:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon (rev 01)
07:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio RNG (rev 01)

You can use the -v option for a more detailed output, -k to list the Linux kernel module in use by the device, and -s to filter specific devices based on their ID. For example, to list kernel modules for device 05:00.0, use:

$ lspci -s 05:00.0 -k
05:00.0 SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)
        Subsystem: Red Hat, Inc. Device 1100
        Kernel driver in use: virtio-pci

The lspci utility provides many other options, so check its man pages for more details.

[ Get the guide to installing applications on Linux. ]

Show RAM information

For basic RAM utilization information, use the command free:

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            3899         269        2616          13        1013        3396
Swap:           3898           0        3898

For additional information about your RAM hardware, including the number and type of slots available, manufacturing information, sizes, and other physical details, use the dmidecode utility. This generic utility provides information about many hardware and firmware components. You can install it with the dmidecode package :

$ sudo dnf install -y dmidecode

Since dmidecode provides a huge dump of information, you can filter its output using the option -t TYPE to list specific types only. For example, to display only RAM-related information, use -t memory:

$ sudo dmidecode -t memory
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
        Location: Other
        Use: System Memory
        Error Correction Type: Multi-bit ECC
        Maximum Capacity: 4 GB
        Error Information Handle: Not Provided
        Number Of Devices: 1

Handle 0x1100, DMI type 17, 40 bytes
Memory Device
        Array Handle: 0x1000
        Error Information Handle: Not Provided
        Total Width: Unknown
        Data Width: Unknown
        Size: 4 GB
        Form Factor: DIMM
        Set: None
        Locator: DIMM 0
        Bank Locator: Not Specified
        Type: RAM
        Type Detail: Other
        Speed: Unknown
        Manufacturer: QEMU
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified
        Rank: Unknown
        Configured Memory Speed: Unknown
        Minimum Voltage: Unknown
        Maximum Voltage: Unknown
        Configured Voltage: Unknown

This command has more capabilities. I'll check some of these out, beginning with the BIOS information.

Display BIOS information

Use dmidecode -t bios to see a summary of your BIOS information:

$ sudo dmidecode -t bios
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x0000, DMI type 0, 26 bytes
BIOS Information
        Vendor: EFI Development Kit II / OVMF
        Version: 0.0.0
        Release Date: 02/06/2015
        Address: 0xE8000
        Runtime Size: 96 kB
        ROM Size: 64 kB
                BIOS characteristics not supported
                Targeted content distribution is supported
                UEFI is supported
                System is a virtual machine
        BIOS Revision: 0.0

The output includes the firmware version and developer information, useful for planning updates.

[ Boost security, flexibility, and scale at the edge with Red Hat Enterprise Linux. ]

Show system information

Finally, for general hardware information, including manufacturing and product serial numbers, use dmidecode -t system:

$ sudo dmidecode -t system
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x0100, DMI type 1, 27 bytes
System Information
        Manufacturer: QEMU
        Product Name: Standard PC (Q35 + ICH9, 2009)
        Version: pc-q35-7.0
        Serial Number: Not Specified
        UUID: 3e45ed98-4c27-4566-8ac0-612cb3e956ba
        Wake-up Type: Power Switch
        SKU Number: Not Specified
        Family: Not Specified

Handle 0x2000, DMI type 32, 11 bytes
System Boot Information
        Status: No errors detected

This information is useful for finding online documentation about your hardware or obtaining vendor support.

What's next?

I've listed some command-line utilities that help you to understand the system and hardware where you run your Linux operating system. Some of these utilities are specialized, while dmidecode is generic. You can see all information that it can provide by using dmidecode -t:

$ sudo dmidecode -t
dmidecode: option requires an argument -- 't'
Type number or keyword expected
Valid type keywords are:

Other high-level utilities provide detailed information about hardware like hwinfo or GUI tools such as cpu-x. I will cover some of these tools in future articles.

Author’s photo

Ricardo Gerardi

Ricardo Gerardi is Technical Community Advocate for Enable Sysadmin and Enable Architect. He was previously a senior consultant at Red Hat Canada, where he specialized in IT automation with Ansible and OpenShift.  More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.