Part 2 · System administration · Lesson 01 · 30 minutes
Identify the system you look after
- Name the distribution, its version and the kernel of a Linux system
- Read the processor, the memory and the disks of a machine
- Tell a real machine from a virtual machine or a container
The lab folder as it stands after this lesson. Unzip it in ~/krlab.
More
The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.
Scenario
A colleague has left the company, and you inherit a server called web7. The ticket says only "Ubuntu server, please patch". Before you touch anything, your lead wants one paragraph: which distribution and version, which kernel, how many processors, how much memory. You cannot log in yet, but your colleague saved the output of four commands in a folder. You learn the commands on your own practice system first, and then you read the saved files.
The idea
Three layers decide what you can do on a system, and Linux keeps a file or a command for each one.
The distribution (distro) is the whole package: the kernel, the programs and the package manager, for example Ubuntu, Debian or Fedora. The kernel is the core of the system. It talks to the hardware and gives programs memory and time on the processor. The version of each decides which commands, packages and fixes you have.
Two kinds of source answer your questions. A file such as /etc/os-release holds text that you read. A command such as lscpu reads the kernel and prints a summary. The folder /proc is a third kind: the kernel makes its files at the moment you read them (lesson 1 of Part 1).
Worked example
Open a terminal on your practice system. The output below comes from a test virtual machine (Ubuntu 24.04, 4 CPUs, 4 GiB of memory, one 20 GiB disk), shortened. Yours will differ, and that is the point of the lesson: you learn where to look.
1. Read the distribution
/etc/os-release is a text file of NAME=value lines that every modern distribution has. head -n 6 prints the first six lines of it.
head -n 6 /etc/os-releasePRETTY_NAME="Ubuntu 24.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.5 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntuThe file is also valid shell code. The command . (dot) runs a file inside your current shell, so each line sets a variable. A script can then ask $ID and $VERSION_ID, and does not need to cut text.
. /etc/os-release
echo "$ID $VERSION_ID $VERSION_CODENAME"ubuntu 24.04 nobleID is the short name of the distribution. ID_LIKE names its parent, for example debian for Ubuntu, which tells you which package manager to expect.
2. Use the other ways to ask
Older systems and other tools give the same fact in other places. lsb_release -d (description) prints one line. hostnamectl shows the host name, the operating system, the kernel and the machine type. ls /etc/*release lists every file whose name ends in release, because each distribution has its own, such as /etc/redhat-release on Red Hat systems.
lsb_release -d
hostnamectl | grep -E 'hostname|Virtualization|Operating|Kernel|Architecture'
ls /etc/*releaseDescription: Ubuntu 24.04.5 LTS
Static hostname: krbox
Virtualization: kvm
Operating System: Ubuntu 24.04.5 LTS
Kernel: Linux 6.8.0-149-generic
Architecture: x86-64
/etc/lsb-release
/etc/os-releaseIf lsb_release is not installed, /etc/os-release still works. Use that file in scripts.
3. Read the kernel
uname (Unix name) prints facts about the kernel. -a (all) prints everything on one line. Single options print one fact: -s the kernel name, -n the host name, -r the release, -m the machine hardware type.
uname -a
uname -r
uname -m
cat /proc/versionLinux krbox 6.8.0-149-generic #149-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 23 13:21:10 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
6.8.0-149-generic
x86_64
Linux version 6.8.0-149-generic (buildd@lcy02-amd64-099) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #149-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 23 13:21:10 UTC 2026x86_64 means a 64-bit Intel or AMD processor; aarch64 is 64-bit ARM. /proc/version adds the compiler and the build date. When a security notice names a kernel version, uname -r is the command that you compare it with.
4. Read the processor and the memory
lscpu (list CPU) prints a summary of the processors. Its fields Thread(s) per core, Core(s) per socket and Socket(s) multiply to the number of logical CPUs that the system shows. nproc prints that number directly. /proc/cpuinfo is the raw list, one block for each logical CPU, and /proc/meminfo is the raw list of memory counters in KiB (1 KiB is 1,024 bytes; the file writes kB). MemTotal is a little less than the memory that you gave the machine, because the kernel keeps a part for itself.
lscpu | grep -E '^(Architecture|Model name|Thread|Core|Socket)'
nproc
grep -c '^processor' /proc/cpuinfo
head -n 2 /proc/meminfoArchitecture: x86_64
Model name: Intel(R) Xeon(R) Platinum 8160 CPU @ 2.10GHz
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
4
4
MemTotal: 3916608 kB
MemFree: 3229444 kB5. List the disks and the devices
lsblk (list block devices) shows the disks and their partitions as a tree. -d (disks only) hides the partitions. lshw (list hardware) reads everything that the system can find. It needs root rights to be complete, and -short gives one line for each device. -class limits it to the kinds that you name.
lsblk -d -o NAME,SIZE,TYPE | grep -v loop
sudo lshw -short -class processor -class memoryNAME SIZE TYPE
sda 20G disk
H/W path Device Class Description
=============================================================
/0/400 processor Intel(R) Xeon(R) Platinum 8160 CPU @ 2.10GHz
/0/1000 memory 4GiB System Memory
/0/1000/0 memory 4GiB DIMM RAM
/0/0 memory 96KiB BIOSgrep -v loop removes the lines that hold the word loop; those are small virtual disks of packages, and you can ignore them. On a virtual machine the disk is usually called sda or vda, and nvme0n1 is the name of a fast NVMe disk.
6. Ask where it runs
systemd-detect-virt prints the kind of virtualisation, or none on a real machine.
systemd-detect-virtkvmkvm or vmware means a virtual machine, and lxc, docker or podman means a container. A container shares the kernel of its host, so you cannot update the kernel from inside it. This matters when a task says "patch the kernel".
In a container (Docker, LXD),
uname -rshows the kernel of the host, andlscpuandlshwcan show the host's CPUs and memory, whilenprocand/proc/meminfoshow your own limit. Size a job bynproc.
7. Name the time zone
A log line holds a time, but not always its zone. In a report, state the zone, or use UTC for everything. The scenario test of this part asks for one zone in a whole timeline. date prints the local time with its zone, date -u prints UTC, and timedatectl shows the zone setting of the system. journalctl --utc prints the journal in UTC. This test machine runs in UTC, so both lines are the same here.
date
date -u
timedatectl | grep -E 'Time zone|synchronized'Sat Nov 21 07:48:04 PM UTC 2026
Sat Nov 21 07:48:04 PM UTC 2026
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yesYour lines show your own time. A clock that drifts breaks the order of events in logs and makes certificates look expired or not yet valid, so a server should say yes on the synchronised line.
Your turn
The saved snapshot of web7 is four files. Save each one under its name in the folder ~/krlab/linux-admin/snapshot (make the folder first with mkdir -p), or take them from the lab files of the course. They are the task data and not the task.
snapshot/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debiansnapshot/uname.txt
Linux web7 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linuxsnapshot/lscpu.txt
Architecture: x86_64
CPU(s): 8
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Model name: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHzsnapshot/meminfo.txt
MemTotal: 8388608 kB
MemFree: 1048576 kB
MemAvailable: 5242880 kBThe ticket said "Ubuntu". Read the files and find the truth. You may use cut, grep and the shell. The tool awk (lesson 5 of Part 1) also helps: awk '{print $3}' FILE prints the third word of each line. Then answer.
Last, write one paragraph for your lead in ~/krlab/linux-admin/snapshot/summary.txt. It names the distribution, the version, the kernel, the number of cores and the memory.
Check yourself
Why should a script read /etc/os-release and not run lsb_release?
/etc/os-release exists on every modern distribution and needs no extra package. lsb_release is a separate package that a minimal system may not have, and some distributions do not ship it.
uname -r prints 6.1.0-18-amd64. What do the first part and the last part tell you?
6.1.0 is the kernel version, and amd64 is the build for 64-bit Intel and AMD processors. The -18 is the build number that the distribution gave to its package of that kernel.
lshw shows 4GiB of memory, and MemTotal in /proc/meminfo shows 3916608 kB. Why is the second number smaller?
lshw reads the hardware, and MemTotal is the memory that the kernel can give to programs. The kernel and the firmware keep a part (here about 270 MiB). The unit of the file is KiB, so 4 GiB is 4194304 kB.
Your lead says "update the kernel on this server". systemd-detect-virt prints "docker". What do you tell your lead?
The system is a container. It uses the kernel of its host, so the update must be done on the host. A package that you install inside the container does not change the running kernel.
Field notes
- Record the facts of a system in one place when you take it over: distribution, version, kernel, architecture, virtual or real, and the date. A server that nobody can describe cannot be patched with confidence.
- A distribution has an end-of-life date. After it, no security fixes come. Check the date of the release that
VERSION_IDnames, because a server without fixes is a finding in any audit. uname -rshows the running kernel, which can differ from the newest kernel installed. After a kernel update, the system runs the old one until a reboot./proc/cpuinfohas aflagsline that lists what the processor can do, for examplevmxorsvmfor virtualisation.lscpualso lists known processor weaknesses in itsVulnerabilitieslines.lshw,dmidecodeandlspciread hardware details and need root. Their output can include serial numbers: do not paste it into a public ticket.