You land on an unknown Linux machine and need to find your bearings. Which distribution? Which kernel version, the core program that drives the hardware? How long has it been running? Any failed services? Which processor (CPU), how much memory (RAM)? This guide lines up the modern commands that answer these questions in a few minutes.
Many of these commands come from systemd, the program that starts the machine and
supervises its services. A service is a program that runs in the background, such
as a web server or a client that sets the clock. Everything systemd manages,
whether a service, a disk mount or a timer, is called a unit. These tools replace
the old lsb_release command, which is no longer installed everywhere.
Command availability was checked on 1 October 2026 on Debian 13, Ubuntu 24.04 and
AlmaLinux 10.2, as were the outputs of os-release and needs-restarting. The
other examples come from an older capture on Ubuntu 24.04, where only the
version numbers differ. Ubuntu 26.04 LTS, the course's reference version, has
not been measured yet for this page: the two points concerned (lsb_release and
last) are flagged in the text.
What you will learn
- Identify the distribution and its version with
os-releaseandhostnamectl - Read the kernel, the architecture and the host name
- Measure the uptime and interpret the load average
- Check the overall systemd state and the failed services
- Take a basic hardware inventory (CPU, memory, disks, PCI, USB)
- Analyse the last startup (boot) with
journalctlandsystemd-analyze
In which context?
Three concrete scenarios:
- You take over an existing server that you did not install: your first reflex is to take stock.
- An incident occurs, for example a slow service or a reboot that went wrong: before looking for the cause, you must know which machine you are working on.
- You audit a fleet of machines running various distributions, and you write a script that collects, for each one, the distribution, the kernel version and the running time (uptime).
These gestures fall under the LFCS (Linux Foundation, Essential Commands section) and RHCSA (Red Hat, Understand and use essential tools section) certifications.
Prerequisites
- A shell with user rights (most commands do not need
sudo) - A system running systemd (Ubuntu 16.04+, Debian 8+, RHEL 7+, Rocky, Fedora), for the
hostnamectl,timedatectlandsystemctlcommands. Thehostnamectl hostnameverb needs a recent systemd (the systemd 249 manual documents it, the 246 one only knowsset-hostname) - The
util-linuxtools (installed by default everywhere) forlscpuandlsblk
Identify the distribution
A distribution is a version of Linux ready to install, such as Ubuntu, Debian or
AlmaLinux. Knowing which one runs on a machine conditions everything else: the
package manager to use (the tool that installs software, such as apt or
dnf), the exact service names and the documentation to open. Three sources
answer the question, and they are not equal: a standardised file present
everywhere, a systemd command that tells you more, and a leftover that is no
longer installed everywhere. Take them in that order.
/etc/os-release, the modern canonical source
This file exists on every systemd distribution. It is standardised: a human reads it with no effort, and a script easily extracts each field.
cat /etc/os-releaseOutput recorded on Ubuntu 24.04 (excerpt):
PRETTY_NAME="Ubuntu 24.04.5 LTS"NAME="Ubuntu"VERSION_ID="24.04"VERSION="24.04.5 LTS (Noble Numbat)"VERSION_CODENAME=nobleID=ubuntuID_LIKE=debianOn AlmaLinux 10.2, from the RHEL family (Rocky Linux likewise shows
ID="rocky"):
NAME="AlmaLinux"VERSION="10.2 (Lavender Lion)"ID="almalinux"ID_LIKE="rhel centos fedora"VERSION_ID="10.2"The ID, VERSION_ID and ID_LIKE fields are what scripts use to write code
that branches by distribution.
hostnamectl, the systemd view
hostnamectl gives a broader summary: distribution, kernel, architecture,
virtualisation and host, all in one command:
hostnamectl Static hostname: master2 Icon name: computer-vm Chassis: vm Machine ID: e84a5b... Boot ID: 3f21a0... Virtualization: kvmOperating System: Ubuntu 24.04.2 LTS Kernel: Linux 6.8.0-58-generic Architecture: x86-64The versions in this output (Ubuntu 24.04.2, kernel 6.8.0-58) come from an older
capture than the os-release one above (24.04.5). On your machine, the numbers
will be different.
The Virtualization line of this output deserves particular attention:
hostnamectl detects on its own whether it runs in a virtual machine (KVM, QEMU,
VMware), in a container (Docker, LXC) or at a cloud provider; on a physical
machine, the line is absent. A virtual machine is a machine simulated by software;
a container is a group of isolated processes that share the kernel of the machine
hosting them. It is often the first thing to establish on an unknown server,
because it decides what is possible: you do not change a kernel parameter or a
hardware setting from inside a container.
lsb_release, the legacy
Historically the reference command, lsb_release is no longer present
everywhere, and that is what rules it out in a script. Ubuntu 24.04 still
installs it. On Debian 13, it is missing from a standard installation, and on
RHEL 10 no package provides it any more. This measurement holds for Ubuntu 24.04:
it remains to be done on Ubuntu 26.04, and nothing allows assuming the same
result. A script that works on Ubuntu therefore fails elsewhere:
lsb_release -a # may return "command not found"Replace it with cat /etc/os-release wherever you come across it.
Identify the host
The host name is read with hostname, and its options are easy to mix up:
-A lists the fully qualified names (FQDN, the host name followed by its
domain), -I the IP addresses, as the command's own help confirms:
hostname # short namehostname -f # FQDN (Fully Qualified Domain Name)hostname -A # all the machine's FQDNshostname -I # all the machine's IP addressesChange the host name persistently (systemd):
sudo hostnamectl hostname admin-prod-01The hostname verb reads the name when you give it no argument and changes it
when you give one. This is the form described by man hostnamectl in recent
systemd releases (257 on Debian 13 and AlmaLinux 10). The older
hostnamectl set-hostname form no longer appears in the help or the manual,
but the binary still recognises it: you will meet it in many tutorials and
scripts.
By default the command changes all three names at once (static, pretty and transient). Three options target only one:
sudo hostnamectl hostname admin-prod-01 --static # permanent name, the one in /etc/hostnamesudo hostnamectl hostname "Admin workstation Stephane" --pretty # human labelsudo hostnamectl hostname admin-prod-01 --transient # ephemeral, reset at rebootIdentify the kernel and the architecture
The uname command exposes everything you need in a single line:
uname -aLinux master2 6.8.0-58-generic #60-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 14 18:29:48 UTC 2025 x86_64 x86_64 x86_64 GNU/LinuxTargeted options:
| Option | What it shows | Use case |
|---|---|---|
-r | Kernel version (6.8.0-58-generic) | Check whether a reboot is needed after an upgrade |
-m | Architecture (x86_64, aarch64) | Pick the right Docker image, the right binary |
-n | Short host name | Alternative to hostname |
-v | Kernel build date | Check how old the installed kernel is |
The arch command (which shows only the equivalent of uname -m) still exists
but adds nothing; prefer uname -m.
To check whether a reboot is needed after a kernel update, each family has its own tool:
# File created by the update-notifier-common package when a reboot is requiredtest -f /var/run/reboot-required && echo "Reboot required" || echo "OK"# Debian does not ship update-notifier-common: needrestart does the jobsudo apt install needrestartsudo needrestart -k# needs-restarting comes with the yum-utils package (dnf-utils is an alias for it)# the "dnf needs-restarting" subcommand comes from dnf-plugins-coresudo dnf install -y yum-utilssudo needs-restarting -rMeasured on AlmaLinux 10.2, the command answers
No core libraries or services have been updated since boot-up. then
Reboot should not be necessary. with exit code 0; it returns exit
code 1 when a restart is required.
Uptime and load
uptime gives in one line the machine's running time and its load:
uptime 18:29:45 up 5 days, 2:15, 1 user, load average: 0.00, 0.01, 0.05The line shows the current time, the uptime (the time since the last startup), the number of connected users and the load average over 1, 5 and 15 minutes. The first three pieces of information are read at a glance: how long the machine has been running, and how many users are connected. The load average, which tells whether the machine is struggling, is less intuitive. The two subsections below explain it, then give the command variants that help when the full line is not enough.
Interpret the load average
The load average gives the average number of processes that are running
(state R) or waiting for a CPU or for a resource such as the disk (input/output,
or I/O). Divide it by the number of cores (nproc) to get a ratio:
nprocuptimenproc prints the number of cores, for example 4. In the uptime line, take
the first of the three load average numbers (the load over 1 minute) and divide
it by that number of cores. A load of 2.0 on a 4-core machine gives a ratio of
0.5.
Ratio load / nproc | Interpretation |
|---|---|
| < 0.7 | Comfortable margin |
| 0.7 – 1.0 | Busy but fine |
| > 1.0 sustained | Saturation, processes are queueing |
These thresholds of 0.7 and 1.0 are a rule of thumb, not a limit set by the kernel: they help spot a machine worth examining, not declare it broken. Also keep in mind that Linux counts processes waiting for the disk in the load. A high load with an idle processor can therefore come from a slow disk, not from a lack of CPU.
To read the load more finely, see Check the system load. For a full diagnosis of the machine, Assess system performance details the USE method (utilisation, saturation, errors).
Useful variants
When only the running time matters to you, two uptime options save you
from reading the whole line. -p gives a readable sentence, -s gives the
exact timestamp of the last boot, handy for matching an incident with the
time of a reboot.
uptime -p # human format: "up 5 days, 2 hours"uptime -s # exact boot date: "2026-04-20 16:14:30"Overall systemd state
One command tells you whether the machine is healthy. It answers with a single word, among eight states:
systemctl is-system-running| Output | Meaning |
|---|---|
running | All good |
degraded | At least one failed unit |
initializing | Early startup, before basic.target is reached |
starting | Late startup, before the job queue is empty for the first time |
stopping | Shutdown in progress |
maintenance | Rescue mode active |
offline | systemd is not running as the system manager |
unknown | State impossible to determine |
Only running returns exit code 0; the other seven states return a non-zero
code, which lets you test the state in a script.
When it says degraded, list the culprits:
systemctl list-units --failedTo see who is connected, loginctl lists the open sessions, then the users:
loginctl list-sessionsloginctl list-userstimedatectl shows the date, the time zone and the state of the clock
synchronisation:
timedatectl Local time: Fri 2026-04-25 14:30:12 CEST Universal time: Fri 2026-04-25 12:30:12 UTC RTC time: Fri 2026-04-25 12:30:12 Time zone: Europe/Paris (CEST, +0200)System clock synchronized: yes NTP service: active RTC in local TZ: noNTP (Network Time Protocol) is the protocol through which the machine sets its
clock from time servers. The System clock synchronized and NTP service lines
are what you check after a reboot to confirm the clock is right. The RTC time
line gives the time of the hardware clock, the one that keeps running while the
machine is off.
Logs and analysis of the last boot
journalctl reads the systemd journal, that is, the messages (logs) of the
machine and its services. It can isolate those of a specific startup:
# logs of the current bootjournalctl -b
# logs of the previous bootjournalctl -b -1
# list of the available boots with their IDsjournalctl --list-bootssystemd-analyze gives the detailed boot time:
# overall viewsystemd-analyze
# Startup finished in 3.481s (kernel) + 41.225s (initrd) + 1min 14.060s (userspace) = 1min 58.766s
# top 10 slowest services at bootsystemd-analyze blame | head -10
# boot timeline as SVG: which unit starts when (useful post-mortem)systemd-analyze plot > boot.svg
# graph of the dependencies between units, to feed to Graphviz (the graphviz package provides the dot command)systemd-analyze dot | dot -Tsvg > dependencies.svgReboot history is read with the last command. It comes from util-linux on
Ubuntu 24.04 and AlmaLinux 10. On Debian 13, it comes from the wtmpdb package,
of standard priority: it is present on a full installation, but not in a
minimal image. Here again, the measurement holds for Ubuntu 24.04 and remains to
be done on Ubuntu 26.04:
last reboot | head -5last -x shutdown | head -5Quick hardware inventory
Six commands sweep through a machine's hardware in 30 seconds.
CPU, lscpu
lscpulscpu describes the processor: architecture, model, number of cores, frequency,
cache. It also reports the state of the mitigations, that is, the protections the
kernel turns on against hardware flaws in processors, such as Spectre and
Meltdown. Each known flaw carries a public identifier called a CVE (for example
CVE-2017-5754 for Meltdown). The lines to remember:
Architecture:x86_64,aarch64,armv7l…CPU(s): logical total (cores × threads per core)Core(s) per socket,Thread(s) per core: actual topologyModel name: exact modelVulnerabilities:: mitigation state per CVE
Memory, free -h
free -hDetailed in Diagnose memory on Linux. For a
first look, the available column is the right metric, not free.
Disks, lsblk
lsblklsblk draws the tree of storage devices: disks, partitions, LVM volumes and
LUKS encrypted volumes. Two commands complement it:
lsblk -f # with file systems and UUIDsdf -hT # space used per mount pointPCI, lspci
lspci | head -20lspci lists the network cards, disk controllers, graphics cards (GPUs) and all
the hardware on the PCI bus. For the details of one device, give its address,
read in the first column:
lspci -v -s 00:1f.6 # verbose mode on the address 00:1f.6USB, lsusb
lsusbUSB devices currently plugged in. Useful to check that a stick, a card reader or a YubiKey is detected.
Virtualisation, systemd-detect-virt
systemd-detect-virtReturns kvm, qemu, vmware, docker, lxc, oracle (VirtualBox), or
none if the machine is physical. A quick equivalent of the Virtualization field of
hostnamectl.
Good practices
These reflexes turn the commands of this guide into a reproducible inventory
routine. The principle is to favour the modern systemd tools
(hostnamectl, systemctl, timedatectl) and the standardised files
(/etc/os-release) over the legacy commands that are no longer installed
everywhere. The health check runs at the very start of an intervention,
before you change anything, to capture the starting state.
hostnamectlfirst on a systemd system: it gives a summary view in a single command./etc/os-releasein scripts, neverlsb_release. It is present everywhere: the. /etc/os-releasecommand (the dot loads the file into the shell) makes the$IDand$VERSION_IDvariables available.systemctl is-system-runningat the start of each intervention: you see straight away whether a service was already down before you touched anything.- After a kernel update, check whether a reboot is required with the tool of your distribution family (see above):
uname -rshows the running kernel, which only changes at reboot. timedatectlevery time after a reboot or a time zone change: clock synchronised, NTP active.lscpuandfree -hin a baseline script produce a flat inventory that is useful for audits.
Quick troubleshooting
The problems you hit while identifying a machine are rarely failures: they are
mostly missing commands or an incomplete configuration (FQDN, NTP).
Read the table starting from the exact message displayed. One row deserves
particular attention: when lscpu reports Vulnerable on some hardware CVEs, it
is not a false positive, it is a kernel whose mitigations are not up to date, to
be treated as a real hardening gap on an exposed server.
| Symptom | Likely cause | Action |
|---|---|---|
hostnamectl: command not found | System without systemd or restricted shell | Fallback: uname -n + cat /etc/os-release |
lsb_release: command not found | Package not installed (the default on Debian 13, absent from RHEL 10) | Do not use it, read /etc/os-release instead |
last: command not found on Debian 13 | last now comes from the wtmpdb package | sudo apt install wtmpdb, or journalctl --list-boots |
hostname -f returns nothing | FQDN not configured in /etc/hosts or DNS | Add a line with the FQDN to /etc/hosts |
uptime shows up 1 min (the duration in minutes under an hour, then up 1:05 beyond) after an unexpected reboot | The machine was restarted (power cut, kernel crash or human action). The OOM killer (Out Of Memory killer, the kernel mechanism that kills a process when memory runs out) does not reboot the machine, unless vm.panic_on_oom is 1 or 2 | journalctl -b -1 | tail to see the previous boot |
systemctl is-system-running returns degraded | A service or a disk mount failed | systemctl list-units --failed for the list |
timedatectl shows NTP service: inactive | No active NTP synchronisation | sudo systemctl enable --now systemd-timesyncd (systemd's lightweight NTP client), or the chrony service if the package is installed (chrony on Debian and Ubuntu, chronyd on RHEL and AlmaLinux) |
lscpu shows Vulnerable on several CVEs | Kernel mitigations missing or turned off | Update the kernel and the microcode (the processor's internal software), then look for mitigations=off in /proc/cmdline, the file that lists the options passed to the kernel at startup |
Key points
/etc/os-releaseis the canonical source for distribution and version, to prefer overlsb_releaseeverywhere.hostnamectlgives in one command: host, kernel, architecture, virtualisation, OS.hostnamectl hostname <name>renames the machine; with no option, all three names (static, pretty, transient) change. The olderset-hostnameis still recognised.uname -r,-mand-nread the kernel, the architecture and the short name.hostname -Alists the FQDNs,hostname -Ithe IP addresses.- With
uptime, divide the load average by the number of cores (nproc) to interpret it. systemctl is-system-runningthensystemctl list-units --failedare the pair for checking overall health.timedatectlchecks time, time zone and NTP synchronisation in one command.journalctl -b -1gives the logs of the previous boot, essential after a crash.systemd-analyze blamelists the slowest services at boot.- For the hardware inventory:
lscpu,free -h,lsblk,lspci,lsusb.
Knowledge check
Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Find your way around Linux files
A new full quiz with random questions
Work again only on the questions you missed