← Full reference

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

OptionWhat it printsExample
no options, -skernel nameLinux
-nnetwork host nameweb01
-rkernel version (release)6.8.0-45-generic
-vkernel build: number and date#45-Ubuntu SMP PREEMPT_DYNAMIC …
-mCPU architecturex86_64, aarch64
-ooperating systemGNU/Linux
-p / -iprocessor type / platform (often unknown or a repeat of -m)
-aeverything at once in the order -s -n -r -v -m -p -i -o

hostname — machine name

OptionWhat it does
no optionshost name (from the kernel; at boot it is taken from /etc/hostname)
-sshort name — up to the first dot
-ffull name (FQDN), via /etc/hosts or DNS
-dDNS domain — the part of the FQDN after the first dot
-iIP addresses the host name resolves to (via /etc/hosts or DNS)
-Iall IP addresses of all network interfaces except loopback
-Aall FQDNs of the machine
hostname new_namechange 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.

PartMeaning
15:22:02current time
up 19 days, 3:31how long the system has been running since the last boot
2 usersnumber of open sessions (from utmp)
load averageaverage load over 1, 5 and 15 minutes
OptionWhat it does
-ponly the running time in words: up 19 hours, 31 minutes
-sboot 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
ColumnMeaning
totalall RAM (or swap)
usedin use: total − available (in procps 4.x, as on Ubuntu 24.04)
freenot used at all
sharedshared memory, mostly tmpfs (/dev/shm, /run)
buff/cachedisk cache and kernel buffers — freed automatically when programs need memory
availablehow much can be allocated to new programs without going to swap — the key number
OptionWhat it does
-hhuman-readable: Gi, Mi (powers of 1024)
-b / -k / -m / -gin bytes / KiB (default) / MiB / GiB
--sipowers of 1000 instead of 1024 (with -h — G, M)
-wwide output: buffers and cache as separate columns
-ta Total line — RAM plus swap
-s Nrefresh every N seconds
-c Ntogether with -s: take N samples and exit
-Leverything on one line
-vshow 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 free is almost always small. Look at available; the warning sign is a small available and growing used in swap.
  • In a container free and uptime show the host. The container's memory limit (docker run -m 256m) isn't visible in free — it's in /sys/fs/cgroup/memory.max, and usage is in /sys/fs/cgroup/memory.current. uname -r and uptime also refer to the host kernel.
  • uname -r is the kernel, not the distribution. Look for the Ubuntu version in /etc/os-release or lsb_release -a.
  • hostname new_name lasts until reboot. For a permanent change you need /etc/hostname or hostnamectl. In an unprivileged container changing the name doesn't work at all.
  • hostname -i resolves the name via /etc/hosts, so it may return 127.0.1.1 or another address from there rather than the network card's address. The real interface addresses — hostname -I or ip -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 D in ps).

See also

top · ps · who-last · df-du · proc · ip