10 System Information
Learning objectives
- Inspect system version, hostname, and uptime.
- Inspect CPU, memory, disk space, and block devices.
- Make a quick judgment about resource pressure.
Command overview
| Command | Purpose | Meaning | Basic usage | Example |
|---|---|---|---|---|
uname | View kernel information | Unix name; shows kernel and architecture information | uname [options] | uname -a |
hostname | View or set hostname | Shows the current machine name | hostname | hostname |
uptime | View uptime and load | Shows uptime, user count, and load average | uptime | uptime |
date | View or set time | Shows current date and time | date | date |
free | View memory | Shows memory and swap use | free [options] | free -h |
df | View disk space | Disk free; shows filesystem free space | df [options] | df -h |
du | View directory use | Disk usage; totals file or directory size | du [options] path | du -sh -- . |
lsblk | View block devices | List block devices; lists disks and partitions | lsblk | lsblk |
lscpu | View CPU information | List CPU; shows CPU architecture and core count | lscpu | lscpu |
Common scenarios
Show system and host information:
uname -a
hostname
date
uptimeView memory:
free -hView disk space:
df -h
df -ihView item sizes in the current directory:
du -sh -- ./*View disks and CPU:
lsblk
lscpuNotes for beginners
-hcommonly means human-readable sizes in KB, MB, and GB.df -hshows filesystem free space;du -shshows actual directory use.df -ishows inodes. Having free capacity does not prove you can create another file.du -sh -- ./*excludes hidden entries and can be slow in a large directory containing many files; a script must state its scan scope.- Interpret
uptimeload average with the CPU core count; it is not a simple percentage. lsblkonly displays devices and partitions. Do not casually format or mount disks.free,ps, anduptimecommonly come from procps-ng;lsblkandlscpufrom util-linux. Minimal containers and macOS/BSD can lack them.- Linux commonly uses free memory as cache. For troubleshooting, focus on
available, swap, and sustained trends rather than thefreecolumn alone. - In a container, commands can show different namespace, cgroup, or host views. Do not automatically interpret output as the container limit.
Read-only resource-evidence exercise
uname -srm
uptime
free -h
df -h -- .
df -ih -- .
du -sh -- .
lscpu | sed -n '1,12p'A report must distinguish a momentary snapshot, trend, and unknowns. Do not claim a root cause from one load or memory output.