uname, hostname, uptime, free
System information — kernel and architecture, host name and IPs, uptime and load, free memory
Four short commands to start getting to know an unfamiliar server: uname — which kernel and architecture, hostname — what the machine is called and which IPs it has, uptime — how long it has been running and how loaded it is, free — how much memory is used and available. The distribution version is shown in the file /etc/os-release.
Syntax
uname [-asnrvmo]
hostname [-s|-f|-d|-i|-I] [new_name]
uptime [-p|-s]
free [-h|-m|-g] [-w] [-t] [-s sec [-c count]]
uname — kernel and architecture
| Option | What it prints | Example |
|---|---|---|
no options, -s | kernel name | Linux |
-n | network host name | web01 |
-r | kernel version (release) | 6.8.0-45-generic |
-v | kernel build: number and date | #45-Ubuntu SMP PREEMPT_DYNAMIC … |
-m | CPU architecture | x86_64, aarch64 |
-o | operating system | GNU/Linux |
-p / -i | processor type / platform (often unknown or a repeat of -m) | |
-a | everything at once in the order -s -n -r -v -m -p -i -o |
hostname — machine name
| Option | What it does |
|---|---|
| no options | host name (from the kernel; at boot it is taken from /etc/hostname) |
-s | short name — up to the first dot |
-f | full name (FQDN), via /etc/hosts or DNS |
-d | DNS domain — the part of the FQDN after the first dot |
-i | IP addresses the host name resolves to (via /etc/hosts or DNS) |
-I | all IP addresses of all network interfaces except loopback |
-A | all FQDNs of the machine |
hostname new_name | change the name until reboot (needs root) |
To change the name permanently on a machine with systemd: hostnamectl set-hostname new_name (it also writes /etc/hostname). Don't forget to update the line with the name in /etc/hosts.
uptime — running time and load
Output: 15:22:02 up 19 days, 3:31, 2 users, load average: 0.52, 0.61, 0.70.
| Part | Meaning |
|---|---|
15:22:02 | current time |
up 19 days, 3:31 | how long the system has been running since the last boot |
2 users | number of open sessions (from utmp) |
load average | average load over 1, 5 and 15 minutes |
| Option | What it does |
|---|---|
-p | only the running time in words: up 19 hours, 31 minutes |
-s | boot date and time: 2026-10-12 19:50:58 |
Load average is the average number of processes that are running or waiting for the CPU (and on Linux also waiting for disk). Compare it with the number of cores (nproc): on 4 cores a load of 4.0 is full utilization, 8.0 — a queue twice as long as the number of cores. If the first number is higher than the third, load is growing right now. Raw data is in /proc/loadavg and /proc/uptime (seconds since boot).
free — memory
total used free shared buff/cache available
Mem: 3.8Gi 2.6Gi 136Mi 21Mi 1.3Gi 1.2Gi
Swap: 4.0Gi 686Mi 3.3Gi
| Column | Meaning |
|---|---|
total | all RAM (or swap) |
used | in use: total − available (in procps 4.x, as on Ubuntu 24.04) |
free | not used at all |
shared | shared memory, mostly tmpfs (/dev/shm, /run) |
buff/cache | disk cache and kernel buffers — freed automatically when programs need memory |
available | how much can be allocated to new programs without going to swap — the key number |
| Option | What it does |
|---|---|
-h | human-readable: Gi, Mi (powers of 1024) |
-b / -k / -m / -g | in bytes / KiB (default) / MiB / GiB |
--si | powers of 1000 instead of 1024 (with -h — G, M) |
-w | wide output: buffers and cache as separate columns |
-t | a Total line — RAM plus swap |
-s N | refresh every N seconds |
-c N | together with -s: take N samples and exit |
-L | everything on one line |
-v | show committed memory and its limit |
The detailed picture is in /proc/meminfo.
Examples
# kernel, architecture and distribution at a glance
uname -srm
grep PRETTY_NAME /etc/os-release
# in a script: put the architecture into a download URL
arch=$(uname -m)
echo "https://example.com/tool-linux-$arch.tar.gz"
# short host name and all IPs
hostname -s
hostname -I
# when the system booted and how many cores — to judge the load average
uptime -s
nproc
cat /proc/loadavg
# memory in convenient units, with a total
free -h -t
# only available memory in MiB — for scripts
free -m | awk '/^Mem:/ { print $7 }'
# watch memory: 5 samples every 2 seconds
free -h -s 2 -c 5
# percentage of memory used
free | awk '/^Mem:/ { printf "%.0f%%\n", ($2 - $7) / $2 * 100 }'
Pitfalls
- "Little free memory" isn't a problem yet. Linux uses free memory for the disk cache, so
freeis almost always small. Look atavailable; the warning sign is a smallavailableand growingusedin swap. - In a container
freeanduptimeshow the host. The container's memory limit (docker run -m 256m) isn't visible infree— it's in/sys/fs/cgroup/memory.max, and usage is in/sys/fs/cgroup/memory.current.uname -randuptimealso refer to the host kernel. uname -ris the kernel, not the distribution. Look for the Ubuntu version in/etc/os-releaseorlsb_release -a.hostname new_namelasts until reboot. For a permanent change you need/etc/hostnameorhostnamectl. In an unprivileged container changing the name doesn't work at all.hostname -iresolves the name via/etc/hosts, so it may return127.0.1.1or another address from there rather than the network card's address. The real interface addresses —hostname -Iorip -br addr.- Load average isn't a percentage. A value of 2.0 on 16 cores is nearly idle, and on one core it's an overload. High load with low CPU usage usually means processes waiting for disk (state
Dinps).