20 Commands to Display System and Hardware Information in Linux
Linux, as a versatile operating system, offers a variety of commands to gather detailed information about your system’s hardware and software configurations. Whether you’re a system administrator, a developer, or a regular user, understanding how to retrieve this information can be incredibly useful. Below are 20 essential commands that can help you display system and hardware information in Linux.
1. uname -a
The uname
command provides basic information about your system. By using the -a
option, you can display all available system information, including the kernel name, version, and architecture.
Example:
uname -a
This command will output something like:
Linux yourhostname 5.15.0-50-generic #55-Ubuntu SMP Wed Sep 28 18:01:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Here, you get the kernel version, system architecture, and other basic details.
2. lsb_release -a
The lsb_release
command provides detailed information about the Linux distribution you are using. This includes the distributor ID, description, release number, and codename.
Example:
lsb_release -a
Output:
Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 Codename: jammy
This is useful for identifying the exact version of your Linux distribution.
3. hostnamectl
The hostnamectl
command provides comprehensive information about your system’s hostname and related details. It is particularly useful for checking the system’s static hostname, pretty hostname, and machine ID.
Example:
hostnamectl
Output:
Static hostname: yourhostname Icon name: computer-vm Chassis: vm Machine ID: 68f2ebc12a5645d3b43207dc3f12c849 Boot ID: 8d5e0983f1aa493fb6a6d50638b50712 Operating System: Ubuntu 22.04 LTS Kernel: Linux 5.15.0-50-generic Architecture: x86-64
4. df -h
The df
command shows the amount of disk space used and available on all mounted filesystems. The -h
option displays this information in a human-readable format (MB, GB).
Example:
df -h
Output:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 25G 22G 54% / tmpfs 1.9G 1.9M 1.9G 1% /dev/shm
5. free -h
The free
command displays the amount of free and used memory in your system. The -h
option shows the values in human-readable format.
Example:
free -h
Output:
total used free shared buff/cache available Mem: 7.8G 2.1G 4.8G 340M 854M 5.1G Swap: 2.0G 0B 2.0G
6. lscpu
The lscpu
command gathers and displays detailed information about the CPU architecture, including the number of CPUs, threads, cores, sockets, and more.
Example:
lscpu
Output:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4
7. lsblk
The lsblk
command lists information about all available block devices on your system, such as hard drives and partitions, in a tree-like format.
Example:
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk └─sda1 8:1 0 50G 0 part /
8. lspci
The lspci
command lists all PCI (Peripheral Component Interconnect) devices connected to your system, such as graphics cards, network cards, and other peripherals.
Example:
lspci
Output:
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 VGA compatible controller: Cirrus Logic GD 5446
9. lsusb
The lsusb
command displays information about all USB (Universal Serial Bus) devices connected to your system.
Example:
lsusb
Output:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
10. inxi -Fxz
The inxi
command is a powerful tool that provides a comprehensive overview of your system’s hardware and software. The -Fxz
options give a full output, omitting sensitive data like MAC addresses and serial numbers.
Example:
inxi -Fxz
Output:
System: Host: yourhostname Kernel: 5.15.0-50-generic x86_64 (64 bit gcc: 7.5.0) Desktop: GNOME 3.36.2 (Gtk 3.24.20) CPU: Quad core Intel Core i5-8250U (-MT-MCP-) cache: 6144 KB
11. dmidecode
The dmidecode
command extracts hardware information from the system’s DMI (Desktop Management Interface) tables, including details about the BIOS, processor, and memory.
Example:
sudo dmidecode
Output (partial):
BIOS Information Vendor: Phoenix Technologies LTD Version: 6.00 Release Date: 07/02/2020
12. top
The top
command provides a dynamic view of system processes, including information about CPU and memory usage. It’s useful for monitoring system performance in real-time.
Example:
top
Output (partial):
top - 12:34:56 up 1:00, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 112 total, 1 running, 111 sleeping, 0 stopped, 0 zombie %Cpu(s): 1.0 us, 0.3 sy, 0.0 ni, 98.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
13. htop
Similar to top
, the htop
command provides a more user-friendly, interactive way to monitor system processes, resource usage, and performance.
Example:
htop
14. lshw
The lshw
(list hardware) command provides detailed information about all hardware components of your system. It includes information on memory, CPU, disks, and network interfaces.
Example:
sudo lshw
Output (partial):
yourhostname description: Notebook product: 20KGS05M00 (LENOVO_MT_20KG_BU_Think_FM_ThinkPad X1 Carbon 6th) vendor: LENOVO
15. cat /proc/cpuinfo
The /proc/cpuinfo
file contains detailed information about the CPU. By using the cat
command, you can view all CPU details.
Example:
cat /proc/cpuinfo
Output (partial):
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 142 model name : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
16. cat /proc/meminfo
Similar to cpuinfo
, the /proc/meminfo
file provides detailed information about the system’s memory usage.
Example:
cat /proc/meminfo
Output (partial):
MemTotal: 8168312 kB MemFree: 4973644 kB MemAvailable: 6012636 kB
17. lsmod
The lsmod
command lists all the loaded kernel modules, which are pieces of code that can be loaded and unloaded into the kernel upon demand. These modules help in the functioning of various hardware components and system features.
Example:
lsmod
Output:
Module Size Used by snd_hda_codec_hdmi 53248 1 x86_pkg_temp_thermal 16384 0
This output shows the currently loaded kernel modules along with their size and the number of times they are used.
18. lscpu
The lscpu
command displays detailed information about the CPU architecture of your system. This command provides essential details like the number of CPUs, cores, threads, sockets, and CPU family, which are crucial for understanding your system’s performance capabilities.
Example:
lscpu
Output:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 Thread(s) per core: 2
This output gives a comprehensive overview of your system’s CPU characteristics.
19. uptime
The uptime
command tells you how long your system has been running. It also provides information about the number of users logged in and the system load averages for the past 1, 5, and 15 minutes.
Example:
uptime
Output:
12:34:56 up 2:34, 1 user, load average: 0.00, 0.01, 0.05
This command is useful for quickly assessing the stability and load of your system over time.
20. dmesg
The dmesg
command displays the kernel ring buffer messages. These messages typically contain information about hardware, drivers, and other kernel-related details during system boot or runtime. It’s particularly useful for diagnosing hardware issues.
Example:
dmesg | less
Output (partial):
[ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct
The output can be quite extensive, so piping it through less
helps you navigate through it more easily.
Conclusion
Understanding how to gather system and hardware information is essential for managing a Linux system effectively. The 20 commands discussed above provide comprehensive insights into various aspects of your system’s hardware and software configuration. These commands are not only useful for troubleshooting and system optimization but also help you better understand the underlying architecture of your Linux environment.
Whether you’re checking the CPU details with lscpu
, monitoring memory usage with free
, or viewing detailed hardware information with lshw
, these commands equip you with the necessary tools to manage your system proficiently. By regularly using these commands, you can ensure that your system runs efficiently and is well-maintained.
Feel free to explore these commands and integrate them into your daily system management tasks. With practice, you’ll become more adept at using these powerful tools to extract valuable information about your Linux system.
Thank you for reading the article! If you found the information useful, you can donate using the buttons below:
Donate ☕️ with PayPalDonate 💳 with Revolut