Introduction
Understanding your Linux system's hardware, kernel, and configuration is essential for troubleshooting, optimization, and documentation. This guide covers 10 essential commands for gathering comprehensive system information.
1. uname - System Information
Display kernel and system information.
# Show kernel name
uname -s
# Show kernel version
uname -r
# Show machine hardware
uname -m
# Show operating system
uname -o
# Show all information
uname -a
# Example output:
# Linux hostname 5.15.0-91-generic x86_64 GNU/Linux
Options: -s=kernel name, -r=kernel release, -m=machine, -o=OS, -a=all
2. hostname - System Hostname
Display or set the system hostname.
# Show current hostname
hostname
# Show short hostname
hostname -s
# Show fully qualified domain name
hostname -f
# Show IP address
hostname -I
# Set hostname permanently
sudo hostnamectl set-hostname newhostname
# Show hostnamectl info
hostnamectl status
3. lscpu - CPU Information
Display detailed CPU architecture information.
# Show all CPU info
lscpu
# Show CPU cores
lscpu | grep -E "^CPU\(s\):"
# Show thread count
lscpu | grep Thread
# Show model name
lscpu | grep "Model name"
# Show cache info
lscpu | grep -i cache
# Output in JSON format
lscpu -J
# Output in parseable format
lscpu -p
4. free - Memory Usage
Display physical and swap memory usage.
# Show memory usage
free
# Show in human-readable format
free -h
# Show in megabytes
free -m
# Show total column
free -t
# Continuous monitoring (1 second)
free -h -s 1
Understanding: total, used, free, shared, buff/cache, available
5. top/htop - System Monitor
Display real-time system and process information.
# Start top
top
# Show specific user
top -u username
# Sort by CPU (press P in top)
top
# Sort by memory (press M in top)
top
# Start htop (if installed)
htop
# htop with specific user
htop -u username
Key Metrics: Load average, CPU usage, Memory usage, Swap usage
6. uptime - System Uptime
Show how long system has been running.
# Show uptime
uptime
# Show only uptime
uptime -p
# Show since boot time
uptime -s
# Show short format
uptime -r
7. dmidecode - Hardware Information
Display hardware components from DMI table.
# Show all hardware info
sudo dmidecode
# Show BIOS info
sudo dmidecode -t bios
# Show system info
sudo dmidecode -t system
# Show motherboard info
sudo dmidecode -t baseboard
# Show processor info
sudo dmidecode -t processor
# Show memory info
sudo dmidecode -t memory
8. lspci - PCI Devices
List PCI devices and hardware components.
# List all PCI devices
lspci
# Verbose output
lspci -v
# Very verbose
lspci -vv
# Show numeric IDs
lspci -nn
# Show kernel drivers
lspci -k
# Show device tree
lspci -t
# Show specific device
lspci | grep -i vga
lspci | grep -i audio
9. lsusb - USB Devices
List USB devices connected to system.
# List all USB devices
lsusb
# Verbose output
lsusb -v
# Show device tree
lsusb -t
# Show specific bus
lsusb -b 1
10. inxi - System Information Tool
Comprehensive system information display.
# Install inxi
sudo apt install inxi
# Show full system info
inxi -F
# Show CPU info
inxi -C
# Show memory info
inxi -m
# Show disk info
inxi -D
# Show network info
inxi -N
# Show sensors (temp, fans)
inxi -s
Quick Reference Table
| Command | Purpose | Example |
|---|---|---|
| uname | Kernel info | uname -a |
| hostname | System name | hostname -f |
| lscpu | CPU details | lscpu |
| free | Memory usage | free -h |
| top/htop | System monitor | top |
| uptime | System uptime | uptime -p |
| dmidecode | Hardware info | dmidecode -t system |
| lspci | PCI devices | lspci -v |
| lsusb | USB devices | lsusb -v |
| inxi | Full system info | inxi -F |
Conclusion
These 10 system information commands enable you to identify hardware components, monitor system resources, troubleshoot performance issues, document system configuration, and verify system specifications.
Related Articles:

454

被折叠的 条评论
为什么被折叠?



