Bookmarks

Linux

Linux is a family of server operating systems based on the Linux kernel. In this reference: Ubuntu and Debian, SSH and sudo, permissions, processes, apt, networking, disks, logs and cron.

checked 1 Nov · next check 8 Nov · 48 min read

Sections
14
Reading
48 min
Current version
ядро 7.3.3; Debian 13.7; Ubuntu 26.04.1
Written from
docs.kernel.org

Check status of the reference

Verified 1 Nov · next check 8 Nov

The sections were compared with the release notes, the check found nothing, and all source links respond.

  1. Verified
  2. Scheduled check

What Linux is and how it is structured

Linux is the kernel of an operating system, and a Linux system means a distribution: the kernel together with the basic utilities, libraries and a package manager. Ubuntu, Debian and RHEL are different distributions on the same kernel, each with its own packages, releases and support periods.

For a server, choose a long-support release: Ubuntu LTS or Debian stable — that is what the projects themselves recommend. Ubuntu interim releases come out every six months and receive updates for only 9 months: they suit those who value fresh software versions over stability.

The system is built in layers. At the bottom is the kernel: it runs the basic housekeeping of the computer and starts the other programs. Programs talk to the kernel only through system calls — the kernel’s entry points — usually not directly, but through wrapper functions of the C library. Everything above the kernel is user space: utilities, services, the shell and applications.

C library wrappers make a system call look like an ordinary function call.

How distributions differ

FeatureUbuntuDebianRHEL
Packagesdeb (apt) and snapdeb (apt), more than 70,000 packagesrpm (dnf)
Releasesevery 6 months; LTS — every 2 yearsa new stable comes regularly; testing and unstable always exist alongsidemajor releases, each followed by minor ones
SupportLTS — 5 years of standard support, interim — 9 months5 years: 3 full and 2 LTS10 years
For a serverLTSstablea supported major release

The examples in this reference are written for Ubuntu LTS and Debian stable. For the RHEL family, a command is given only when it differs — for example, dnf instead of apt.

Prerequisites

  • Working in the terminal: commands, quotes, redirection and pipes — the Bash reference
  • Services, how they run and their log — the systemd reference
  • Securing a server: SSH, a firewall, security updates — the “Securing Linux servers” reference
  • Addresses, subnet masks, routes and DNS as concepts — the “TCP/IP and DNS” reference

Section sources

the section is written from these pages

Cheat sheet

Everyday commands for an Ubuntu or Debian server; each one is covered in its own section. Replace the names in the examples (aziz, web1, /srv/app) with your own.

Files and search

TaskCommand
Where am Ipwd
Detailed listing including hidden filesls -la
Create a directory together with its parentsmkdir -p /srv/app/releases
Copy a directory with permissions and timestampscp -a /srv/app /srv/app.bak
Move or renamemv app.conf app.conf.old
Symbolic linkln -s /srv/app/releases/42 /srv/app/current
Logs unchanged for 8 days or morefind /var/log -name "*.log" -mtime +7
Archive a directorytar -czf app.tar.gz /srv/app
Extract into a directorytar -xzf app.tar.gz -C /tmp

Users and permissions

TaskCommand
Current user and groupsid
Create a usersudo adduser aziz
Add to a group without removing from the otherssudo usermod -aG deploy aziz
Permissions rw-r-----chmod 640 config.env
Change the owner recursivelysudo chown -R www-data:www-data /var/www/site
Root shellsudo -i

Processes

TaskCommand
All processesps aux
Process treeps -ef --forest
PID and command line by namepgrep -a nginx
Stop gracefullykill 1234
Stop forciblykill -KILL 1234
Load in real timetop

Packages

TaskCommand
Update the package listssudo apt update
Upgrade installed packagessudo apt upgrade
Installsudo apt install htop
Remove along with its configurationsudo apt purge htop
Remove dependencies that are no longer neededsudo apt autoremove
Which package owns a filedpkg -S /etc/host.conf
Install on RHELsudo dnf install htop

Network

TaskCommand
Interface addresses in briefip -br addr
Routesip route
Listening ports and their processessudo ss -tulpn
Apply Netplan with rollbacksudo netplan try
Change the hostnamesudo hostnamectl hostname web1
Copy a file to the serverscp app.tar.gz aziz@203.0.113.10:/tmp/

Disks, logs, cron

TaskCommand
Free spacedf -h
Free inodesdf -i
Largest directories in /varsudo du -xh --max-depth=1 /var | sort -h
Disks, partitions, UUIDslsblk -f
Follow the logsudo tail -f /var/log/syslog
Kernel messagessudo dmesg -T
Your cron jobscrontab -l

Dangerous commands

TaskCommand
Delete a directory with all its contentsrm -rf /srv/app/tmp
Create a filesystem on a partitionsudo mkfs.ext4 -L data /dev/sdb1
Delete your entire crontabcrontab -r

Section sources

the section is written from these pages

Access and initial setup

You log in to a server over SSH: ssh aziz@203.0.113.10. Work as your own user and run administrator commands with sudo, using your own password: in Ubuntu the root account is locked, so you cannot log in as root directly.

Logging in over SSH

The ssh client connects to the sshd service on the server and, after authentication, opens a shell or runs a single command. -p sets the port and -i the key file. On the first connection ssh shows the server’s key fingerprint and stores the key in ~/.ssh/known_hosts. If the key changes later, ssh warns you and disables password login.

bashon your computer
ssh aziz@203.0.113.10# a different port and keyssh -p 2222 -i ~/.ssh/id_ed25519 aziz@203.0.113.10# run one command and exitssh aziz@203.0.113.10 uptime

If the server does not have an SSH server yet, install it from the console:

bashon the server
sudo apt install openssh-server

Logging in with a key

With a key you need no password: the server keeps the public key, and the private key stays with you alone. Create an ed25519 key pair — the algorithm the Ubuntu documentation recommends — and copy the public key to the server with ssh-copy-id, which appends it to ~/.ssh/authorized_keys.

bashon your computer
ssh-keygen -t ed25519ssh-copy-id aziz@203.0.113.10# the server no longer asks for a passwordssh aziz@203.0.113.10

ssh-keygen offers to set a passphrase for the private key — set one. The private key is saved to ~/.ssh/id_ed25519 and the public key to ~/.ssh/id_ed25519.pub. On the server, only its owner should be able to write to authorized_keys; if the permissions are wider, fix them:

bashon the server
chmod go-w ~/.ssh/authorized_keys

Short server names

To avoid typing the address, port and key every time, describe the server in ~/.ssh/config and log in by a short name. Host is the name, HostName is the address, and User, Port and IdentityFile replace -l, -p and -i. The file should be writable only by you.

text~/.ssh/config
Host web1    HostName 203.0.113.10    User aziz    Port 2222    IdentityFile ~/.ssh/id_ed25519
bashon your computer
ssh web1

Administrator rights: sudo

sudo runs a command as root and asks for your own password; after you enter it, it does not ask again for a while. In Ubuntu, the sudo group grants the right to use sudo: the user created during installation is already a member.

bashon the server
# one command as rootsudo apt update# a root shell with root’s environmentsudo -i# a command as another usersudo -u www-data ls /var/www# which commands you may runsudo -l

The sudo rules are stored in /etc/sudoers. Edit them only with visudo: it checks the syntax before saving, and a mistake in the rules can take sudo away from you.

bashon the server
sudo visudo

Since Ubuntu 25.10, the sudo command is provided by default by sudo-rs, an implementation in Rust. Typical use works as before, and the original sudo remains on the system as sudo.ws.

Copying files: scp

scp copies files over SSH with the same authentication as logging in; the data is transferred using the SFTP protocol. A remote path is written as user@host:path, -r copies a directory, and the port is set with a capital -P: a lowercase -p preserves file times and permissions.

bashon your computer
# a file to the serverscp app.tar.gz aziz@203.0.113.10:/tmp/# a directory from the server to your computerscp -r aziz@203.0.113.10:/srv/app/config ./config# a non-default portscp -P 2222 app.tar.gz aziz@203.0.113.10:/tmp/

First server setup

  1. Log in as the user created during installation and check your rights: sudo -v.
  2. Create a user for yourself and give it sudo: sudo adduser aziz, then sudo adduser aziz sudo.
  3. Copy your key with ssh-copy-id and test key login in a new window.
  4. Install updates — the commands are in the “Packages: apt and dnf” section.
  5. Set the hostname — see the “Networking: ip, ss and configuration” section.
  6. Disable password login — see the “Securing Linux servers” reference, “SSH” section.

Section sources

the section is written from these pages

The filesystem and paths

All files in Linux live in a single directory tree rooted at /: disks and partitions are mounted into its branches rather than appearing as separate drive letters. What goes where is set by the Filesystem Hierarchy Standard (FHS): configuration in /etc, variable data and logs in /var, programs in /usr.

A path that starts with / is counted from the root (/var/log/syslog); the rest are counted from the current directory, which pwd shows. .. is the parent directory, ~ is the home directory: the shell expands it. /dev holds device files. /proc and /sys are pseudo-filesystems: the information about processes and the kernel is supplied by the kernel itself; none of it is on disk.

The pseudo-filesystem is marked with a dashed line; the full list of directories is in the table.
DirectoryWhat it holds
/etcConfiguration for this machine
/homeUsers’ home directories
/rootroot’s home directory
/varData that grows and changes: queues, caches, logs
/var/logLogs
/var/libProgram state
/usr/bin, /usr/sbinPrograms: essential ones and administration tools
/usr/localPrograms installed manually on this machine
/optAdd-on software packages
/srvData served by this server’s services
/tmpTemporary files: may be deleted without warning
/devDevice files
/proc, /sysInformation about processes and the kernel
/mnt, /mediaMount points for temporary and removable media
/bootBoot loader files

Essential commands

CommandWhat it does
ls -laA listing with permissions, owner, size and hidden files
cd -Go back to the previous directory
mkdir -p a/b/cCreate a directory together with any missing parents
cp -a SRC DESTCopy a directory whole, preserving permissions, owner and timestamps
mv SRC DESTMove or rename
rm -r DIRDelete a directory with all its contents
touch FILECreate an empty file or update the modification time
cat FILEPrint a file in full
less FILEScroll through a file page by page
head -n 20 FILE, tail -n 20 FILEFirst and last 20 lines

Files whose name starts with a dot are hidden: ls shows them only with -a. Patterns like *.log are expanded by the shell — the Bash reference covers this in detail.

Links and inodes

An inode is a filesystem record with all the information about a file; a name in a directory merely points to an inode. A hard link is another name for the same inode, indistinguishable from the first. It cannot be created on another filesystem and, as a rule, not on a directory. A symbolic link is a separate file that stores the name of its target; if the target is deleted, the link remains and leads nowhere.

bashon the server
# a symbolic link current -> releases/42ln -s /srv/app/releases/42 /srv/app/currentls -l /srv/app/current# the inode number and the number of hard linksls -li /etc/hostname

To switch the link to a new release, replace it: -f removes the old one, and -n prevents the new link from being created inside the directory the old one points to.

bashon the server
ln -sfn /srv/app/releases/43 /srv/app/current

Finding files: find

find walks the tree from the given directory and tests each file against conditions: name, type, modification time, size. A number with + means “more than”, and with - it means “less than”. find counts time in whole days and discards the remainder, so -mtime +7 finds files modified 8 or more days ago.

bashon the server
# by name, case-insensitivefind /etc -iname "*.conf"# unchanged for 8 days or morefind /var/log -name "*.log" -mtime +7# files over 100 MiB on the root filesystemsudo find / -xdev -type f -size +100M# run a command on everything foundfind /srv/app -name "*.sh" -exec chmod 750 {} +

Archives: tar

tar packs a directory into a single archive file, with -z a gzip-compressed one. Modes: -c creates, -t lists the contents, -x extracts; -f sets the archive name, and -C the directory to extract into. tar strips the leading / from paths, so the archive of /srv/app extracts into /tmp/srv/app.

bashon the server
tar -czf app-2026-10-31.tar.gz /srv/apptar -tzf app-2026-10-31.tar.gztar -xzf app-2026-10-31.tar.gz -C /tmp

Section sources

the section is written from these pages

Users, groups and permissions

A file’s permissions are three sets of letters rwx: one for the owner, one for the file’s group and one for everyone else. chmod changes them, and chown changes the owner and group. adduser and addgroup create users and groups, and usermod -aG adds a user to a group.

Users and groups

Local users are listed line by line in /etc/passwd, groups in /etc/group and encrypted passwords in /etc/shadow. Root has user ID (UID) 0. In Ubuntu, system users that appear when services are installed get UIDs from 100 to 999, and regular users start at 1000.

bashon the server
# who I am and which groups I am inidid aziz# a user’s linegrep aziz /etc/passwd
Command (Ubuntu and Debian)What it does
sudo adduser azizCreate a user with a home directory; it asks for a password
sudo addgroup deployCreate a group
sudo adduser aziz deployAdd a user to a group
sudo usermod -aG deploy azizThe same via usermod
sudo passwd -l azizLock the password; -u unlocks it
sudo deluser azizDelete the user; the home directory stays in place

How to read permissions

ls -l shows permissions as ten characters: the first is the type (- file, d directory, l symbolic link), then three letters each for the owner, the group and everyone else. On a file, r means read, w means modify and x means execute. On a directory, r means seeing the list of files, w means creating and deleting files in it, and x means reaching the files inside.

Each triple is one octal digit: r = 4, w = 2, x = 1, and the values add up. rwxr-x--- is 750: the owner can do everything, the group can read and execute, and nobody else can do anything.

PermissionsNumberWhere it is typical
rw-r--r--644Ordinary files: the owner modifies them, everyone reads them
rw-r-----640Settings with secrets that a service’s group reads
rw-------600Private keys and personal files
rwxr-xr-x755Programs and directories open to everyone for reading
rwxr-x---750The owner’s and the group’s directories; Ubuntu creates home directories this way

chmod, chown and chgrp

bashon the server
# as a number: rw-r-----chmod 640 /srv/app/config.env# in letters: give the group write accesschmod g+w /srv/app/uploads# take write away from the group and otherschmod go-w ~/.ssh/authorized_keys# owner and group, recursivelysudo chown -R www-data:www-data /var/www/site

To give directories the entry permission recursively while leaving files without it, use capital X: it sets x only on directories and on files that were already executable.

bashon the server
chmod -R u=rwX,g=rX,o= /srv/app

umask: permissions of new files

A new file gets the permissions the program requested, minus the bits set in the umask mask. This is not subtraction of numbers: with the mask 027, a file that requested 666 gets 640. A typical mask is 022: a file created with 666 gets 644, and a directory created with 777 gets 755. The umask command shows the mask, and with an argument sets it for the current shell.

bashon the server
umask# new files are unreachable to othersumask 027

setuid, setgid and the sticky bit

Three special bits change the behaviour of programs and directories:

  • setuid (u+s, 4000): the program runs with the file owner’s permissions.
  • setgid (g+s, 2000): the program runs with the file group’s permissions, and new files in such a directory get the directory’s group — this is how shared team directories are arranged.
  • the sticky bit (+t, 1000): only the file’s or the directory’s owner can delete or rename a file in the directory, as in /tmp.

In ls -l these bits appear as s and t in place of x.

bashon the server
# a shared directory for the deploy groupsudo mkdir -p /srv/sharedsudo chgrp deploy /srv/sharedsudo chmod 2775 /srv/shared

Besides the rwx bits, a file can have file system attributes (set, for example, by chattr) and access control lists (ACL). For instance, a file with the “immutable” attribute cannot be modified even if chmod a+w allowed writing.

Section sources

the section is written from these pages

Processes and signals

A process is a running program with its own PID; every process has a parent (PPID). ps aux shows the list of processes, top shows the load in real time. A process is stopped with a signal: the gentle SIGTERM first, and SIGKILL only if that did not help.

What is running: ps

bashon the server
# all processes, BSD formatps aux# all processes, the standard format with PPIDps -ef# the process treeps -ef --forest# custom columns, the biggest memory consumers firstps -eo pid,ppid,user,%mem,%cpu,cmd --sort=-%mem
ColumnWhat it means
PID, PPIDThe process number and its parent’s number
%CPUCPU time divided by the process’s elapsed run time: not the instantaneous load
%MEMThe share of physical memory the process takes up
RSSThe process’s physical memory, KiB
VSZThe process’s virtual memory, KiB
STATThe process state: the first letter is the state itself, what follows are flags

Process states

A running process (R) goes into waiting for an event (S) or for input/output (D) and comes back. The SIGSTOP signal stops it (T), SIGCONT resumes it. A finished process stays a zombie (Z) until its parent collects its exit code.

The letters are what ps shows in the STAT column.
LetterState
RRunning or ready to run
SAsleep, waiting for an event
DUninterruptible sleep, usually waiting for input/output
TStopped by a job control signal
ZZombie: terminated, but the parent has not collected the exit code yet
IIdle kernel thread

Many processes in state D usually mean they are waiting for slow input/output, most often a disk. Many zombies mean the parent process is not collecting the exit codes of its children.

Signals and kill

A signal is a notification a process receives from the kernel or another process. By default kill sends SIGTERM: the program can catch it, finish its work and save its data. SIGKILL cannot be caught: the process is terminated immediately, without cleaning up after itself, so send it only if SIGTERM did not help.

SignalNumberDefault actionWhen it arrives
SIGTERM15Terminates the processA normal stop, plain kill
SIGKILL9Terminates, cannot be caughtThe process ignores SIGTERM
SIGINT2Terminates the processAn interrupt from the keyboard
SIGHUP1Terminates the processThe controlling terminal has closed
SIGSTOP19Stops, cannot be caughtThe process needs to be suspended
SIGCONT18Resumes a stopped processThe process needs to be resumed
bashon the server
kill 1234# the same, with the signal given explicitlykill -TERM 1234# only if the process did not terminatekill -KILL 1234# the list of signalskill -l

Signal numbers apply to x86 and ARM; on other architectures they can differ, while the names stay the same.

Find by name: pgrep and pkill

bashon the server
# the PID and the full command linepgrep -a nginx# a user’s processes with namespgrep -u www-data -l# stop by command line (SIGTERM)pkill -f "python3 worker.py"

top: the load in real time

The first line of top shows the system uptime and the load average over 1, 5 and 15 minutes. Below it are memory and the list of processes; the keys change how the list looks:

KeyAction
PSort by %CPU
MSort by %MEM
kSend a signal to a process; SIGTERM by default
rChange the nice value
1Show each processor separately
qQuit

The nice value (the NI column) sets the priority: a positive value lowers the process’s priority, a negative one raises it. An ordinary user can only increase nice.

Background shell jobs (&, jobs, fg, bg) are covered in the Bash reference. Services are also processes, managed by systemd: see the systemd reference for details.

Section sources

the section is written from these pages

Packages: apt and dnf

In Debian and Ubuntu, software is installed as deb packages from the distribution’s repositories, and APT manages them — the command is apt. Update the package list first (sudo apt update), then install and upgrade: otherwise APT knows nothing about the new versions.

Daily commands

CommandWhat it does
sudo apt updateDownloads a fresh package list from all the sources
sudo apt upgradeUpgrades installed packages; installs new ones only for dependencies, removes nothing
sudo apt full-upgradeThe same, but it may remove packages if the system cannot be upgraded otherwise
sudo apt install nginxInstalls a package with its dependencies; you can list several
sudo apt remove nginxRemoves a package, keeping modified configuration files
sudo apt purge nginxRemoves a package together with its configuration
sudo apt autoremoveRemoves dependencies that nothing needs any more
apt search nginxSearches the list of available packages
apt show nginxThe version, dependencies, size and description of a package
apt list --installedInstalled packages; --upgradeable — those that can be upgraded

apt is meant for use in a terminal, and its behaviour may change between versions. In scripts use apt-get and apt-cache: the syntax of their main commands is the same.

On Ubuntu Server, security updates are installed automatically by default.

What is installed and whose file is it: dpkg

APT works on top of dpkg: dpkg installs and removes individual packages, but it does not download them or pull in dependencies itself. What apt does is recorded in /var/log/dpkg.log.

bashon the server
# is the package installeddpkg -l | grep openssh# which files the package installeddpkg -L openssh-server# which package owns a filedpkg -S /etc/host.conf
textexample output of dpkg -S
base-files: /etc/host.conf

Package sources

The repositories are listed in files under /etc/apt/sources.list.d/. Since 24.04 Ubuntu describes its repositories in the deb822 format in the file ubuntu.sources; in older releases they are listed in /etc/apt/sources.list. An entry says where to fetch packages from (URIs), for which release (Suites), which components (Components) and which key verifies the signature (Signed-By).

textsources.list.d/ubuntu.sources
Types: debURIs: http://archive.ubuntu.com/ubuntuSuites: resolute resolute-updates resolute-backportsComponents: main universe restricted multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

A third-party repository

A third-party repository is connected with a separate .sources file and its own key. Do not add the key with apt-key: the entry gives the path to it in Signed-By.

bashon the server
sudo wget -O /usr/share/keyrings/example.asc \  https://repo.example.com/ubuntu/example.asc
textsources.list.d/example.sources
Types: debURIs: https://repo.example.com/ubuntuSuites: resoluteComponents: mainSigned-By: /usr/share/keyrings/example.asc
bashon the server
sudo apt update

On Ubuntu, some software is distributed as snap packages (snap install): they carry their dependencies with them and run in a sandbox.

apt and dnf

On Fedora and in the RHEL family, rpm packages are installed with dnf — the successor to yum with the same syntax. How the commands map:

Taskaptdnf
Upgrade everythingsudo apt update && sudo apt upgradesudo dnf upgrade
Check for updatesapt list --upgradeablednf check-update
Installsudo apt install htopsudo dnf install htop
Removesudo apt remove htopsudo dnf remove htop
Remove unneeded dependenciessudo apt autoremovesudo dnf autoremove
Findapt search htopdnf search htop
About a packageapt show htopdnf info htop

Release upgrade of Ubuntu

Upgrading packages does not change the release: to move to the next release, run do-release-upgrade. With an LTS you can move only to the next LTS and only after its first point release — of the form x.04.1 — is out.

  1. Make a backup of your data.
  2. Install every update of the current release; if the file /run/reboot-required exists, reboot.
  3. Check the free space: hundreds of packages will be downloaded.
  4. Run sudo do-release-upgrade and answer its questions. Configuration files you have changed are kept by default.
  5. Reboot the server: without a reboot the upgrade is not complete.
bashon the server
sudo apt update# every update, including phased onessudo apt full-upgrade \  -o APT::Get::Always-Include-Phased-Updates=truesudo do-release-upgrade

Section sources

the section is written from these pages

Text processing: grep, sed, awk

Logs and configuration files are plain text, and a chain of small utilities picks them apart: grep selects lines, sort and uniq count repeats, sed replaces text, awk works with columns. The output of one command becomes the input of the next through |.

grep: find lines

bashon the server
# case-insensitive, with line numbersgrep -in "error" /var/log/syslog# in every .conf file in the directory and its subdirectoriesgrep -rn --include="*.conf" "Port" /etc/ssh# without comments or empty linesgrep -Ev '^(#|$)' /etc/ssh/sshd_config# 3 lines before and after the matchgrep -C 3 "timeout" /var/log/syslog
FlagWhat it does
-iIgnore case
-vSelect lines without a match
-nShow the line number
-rSearch every file in the directory and its subdirectories
-EExtended regular expressions: |, +, () without a backslash
-FSearch for the string as is, not as a regular expression
-wWhole words only
-cThe number of matching lines instead of the lines themselves
-lOnly the names of files with matches
-oOnly the matching parts of a line
-C 33 lines of context before and after

The grep exit code: 0 — lines were found, 1 — not found, 2 — an error. Checks in scripts are built on this.

sort, uniq, cut, wc: counting

bashon the server
# number of lineswc -l /var/log/syslog# first field, the separator is a coloncut -d: -f1 /etc/passwd# which shells the users have, and how many timescut -d: -f7 /etc/passwd | sort | uniq -c | sort -rn

uniq merges only adjacent identical lines, so sort almost always comes before it. In sort, -n sorts numerically, -r in descending order, -h by sizes with the K, M, G suffixes, -k 2,2 by the second field. Without a second number, -k 2 takes everything from the second field to the end of the line.

tr replaces and deletes characters: tr -d '\r' < win.txt > unix.txt strips carriage returns from a file created in Windows. tail -f prints new lines as they are written, and tail -F also reopens the file when it is replaced during rotation.

sed: replace text

bashon the server
# replace in the output, the file is left unchangedsed 's/8080/8081/g' app.conf# replace in the file, the previous version kept as app.conf.baksed -i.bak 's/8080/8081/g' app.conf# show only lines 10–20sed -n '10,20p' app.conf

awk: columns and sums

awk splits each line into fields on spaces and tabs: $1 is the first field, $NF the last, NR the line number; -F changes the separator. A program consists of “condition { action }” pairs, and the END block runs after the last line.

bashon the server
# each user’s name and shellawk -F: '{ print $1, $7 }' /etc/passwd# users with a UID of 1000 or higherawk -F: '$3 >= 1000 { print $1 }' /etc/passwd# sum of the fifth column, the file sizesls -l /var/log | awk '{ sum += $5 } END { print sum }'

Recipe: the most frequent addresses in a log

If the client address is the first field of a log line, awk, sort, uniq and head give the ten most frequent addresses:

bashon the server
awk '{ print $1 }' access.log \  | sort | uniq -c | sort -rn | head -10
textexample output
   1520 198.51.100.23    842 203.0.113.7    311 192.0.2.44...

GNU coreutils and rust-coreutils in Ubuntu

Since Ubuntu 25.10 the basic utilities (ls, cat, sort and others) come from rust-coreutils by default rather than from GNU coreutils. Compatibility is still incomplete, so cp, mv and rm are still taken from GNU, and the GNU version of any utility can be run with the gnu prefix.

bashon the server
# the GNU version of lsgnuls -la# bring GNU coreutils back in fullsudo apt install coreutils-from-gnu \  coreutils-from-uutils- --allow-remove-essential

Section sources

the section is written from these pages

Networking: ip, ss and configuration

The current state of the network is shown by ip: interfaces (ip -br link), addresses (ip -br addr) and routes (ip route). Changes made with ip last until a reboot; permanent configuration in Ubuntu is set by Netplan files in /etc/netplan/.

A server usually has two interfaces: the lo loopback with address 127.0.0.1 and a network card — eth0, eno1 or enp0s25; names vary. Packets to your own subnet go directly, everything else goes to the gateway over the default route (shown as default via in the output of ip route).

The 127.0.0.53 resolver is the local systemd-resolved service in Ubuntu.

Interfaces, addresses and routes

CommandWhat it shows
ip -br linkInterfaces and their state
ip -br addrInterface addresses, briefly
ip addr show dev eth0Everything about the addresses of one interface
ip routeThe routing table
ip neighThe neighbour table: IP and MAC addresses on the local network
ip -j addrThe same in JSON — for scripts
bashon the server
ip route
textexample output
default via 192.0.2.1 dev eth0 proto dhcp src 192.0.2.10 metric 100192.0.2.0/24 dev eth0 proto kernel scope link src 192.0.2.10

default via 192.0.2.1 is the gateway through which everything that doesn’t match the other routes goes out. 192.0.2.0/24 dev eth0 is your own subnet behind the eth0 interface.

Temporary changes

bashon the server
sudo ip addr add 192.0.2.20/24 dev eth0sudo ip addr del 192.0.2.20/24 dev eth0sudo ip link set dev eth0 upsudo ip route add default via 192.0.2.1

Permanent configuration: Netplan

Netplan reads YAML files from /etc/netplan/ and passes the configuration to the systemd-networkd service (renderer: networkd). A static address, gateway and DNS look like this:

yaml/etc/netplan/99_config.yaml
network:  version: 2  renderer: networkd  ethernets:    eth0:      addresses:        - 192.0.2.10/24      routes:        - to: default          via: 192.0.2.1      nameservers:        search: [example.com]        addresses: [192.0.2.53, 198.51.100.53]

Apply changes with netplan try: it enables the new configuration and rolls it back after 120 seconds if you do not confirm. On a remote server this is insurance against losing access. netplan apply applies the configuration without a rollback.

bashon the server
sudo netplan trysudo netplan apply# current state: addresses, routes, DNSnetplan status

Which ports the server listens on: ss

bashon the server
# listening TCP and UDP, as numbers, with processessudo ss -tulpn# incoming SSH connections to the serverss -tn state established '( sport = :22 )'
FlagWhat it does
-t, -uTCP and UDP sockets
-lListening sockets only
-aBoth listening and established connections
-nPorts as numbers, without service names
-pThe processes holding the sockets
-sSummary statistics

DNS and /etc/hosts

In Ubuntu, names are resolved by the systemd-resolved service: /etc/resolv.conf is a link to its file /run/systemd/resolve/stub-resolv.conf. DNS servers are set in Netplan (nameservers), temporarily — with the resolvectl dns command, and such settings are reset with resolvectl revert. By default, entries in /etc/hosts take precedence over DNS.

bashon the server
# set DNS for an interface temporarilysudo resolvectl dns eth0 192.0.2.53# reset the DNS settings of an interface in systemd-resolvedsudo resolvectl revert eth0
text/etc/hosts
127.0.0.1   localhost127.0.1.1   web1192.0.2.11  db1 db1.example.com

Hostname

hostnamectl shows and changes the server’s name. The name uses lowercase Latin letters, digits and hyphens; several parts separated by dots are allowed, up to 64 characters in total. Add the new name to /etc/hosts as well, with the line 127.0.1.1 web1.

bashon the server
hostnamectlsudo hostnamectl hostname web1

Checking connectivity

ping checks whether a host responds. If the host is reachable but the port is closed from the outside, check whether a service is listening on it (ss) and the firewall — the reference “Securing Linux servers”, section “Firewall”. Network concepts — addresses, masks, routing — are covered in the reference “TCP/IP and DNS”.

bashon the server
ping 192.0.2.1

Section sources

the section is written from these pages

Disks and file systems

A Linux disk is a device file such as /dev/sdb, and its partition is /dev/sdb1. To store files on a partition, you create a file system on it (mkfs.ext4) and mount it on a directory, the mount point. A permanent mount is recorded in /etc/fstab.

What is attached: lsblk

bashon the server
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS# file system type, UUID, free space, mount pointlsblk -f
textexample output
NAME     SIZE TYPE MOUNTPOINTSsda       40G disk├─sda1     1G part /boot/efi└─sda2    39G part /sdb      100G disk

A new disk with no partitions appears as a disk with no children. The FSUSE% and FSAVAIL columns of lsblk -f show how much space is used and free on each file system. For a per-directory breakdown with df and du, see the “Common errors and troubleshooting” section.

A new disk: partition, file system, mount

  1. Find the disk in lsblk and make sure it is empty.
  2. Create a partition on it, for example with sudo fdisk /dev/sdb.
  3. Create a file system: sudo mkfs.ext4 -L data /dev/sdb1.
  4. Mount it on an empty directory.
  5. Record the mount in /etc/fstab by UUID and check the file.
bashon the server
sudo mkfs.ext4 -L data /dev/sdb1sudo mkdir -p /srv/datasudo mount /dev/sdb1 /srv/data

The -L label can be up to 16 bytes. By default, ext4 reserves 5% of blocks for root, so root services keep working after ordinary processes have filled the disk.

Permanent mounts: /etc/fstab

Each line of /etc/fstab has six fields. Identify the device by UUID=: names like /dev/sdb1 depend on the order in which the system detected the disks, and they change when disks are added or removed. lsblk -f shows the UUID.

text/etc/fstab
UUID=6f1c2a9e-4b7d-4e2a-9c53-1d8e0b7a4f21 /srv/data ext4 defaults,nofail 0 2
FieldIn the exampleMeaning
1UUID=…What to mount
2/srv/dataWhere to mount it: the mount point
3ext4File system type
4defaults,nofailOptions; nofail suppresses the error if the disk is missing
50Field for dump; 0 means not needed
62fsck check order: 1 is the root, 2 is everything else, 0 means do not check

After editing, check the file, reload the systemd configuration and mount everything from fstab:

bashon the server
sudo findmnt --verifysudo systemctl daemon-reloadsudo mount -alsblk -f /dev/sdb1

LVM: volumes you can grow

LVM (Logical Volume Manager) combines partitions into a shared pool and carves logical volumes out of it. A physical volume (PV) is a partition handed over to LVM. A volume group (VG) is a pool of one or more PVs. A logical volume (LV) is a “partition” inside the group, and you create a file system on it. A logical volume grows using the free space of the group, without touching the disk partitions.

It does not matter how many disks are in the group: the file system sees a single logical volume.
bashon the server
# partitions of two disks into one group, datasudo pvcreate /dev/sdc1 /dev/sdd1sudo vgcreate data /dev/sdc1 /dev/sdd1sudo lvcreate --name pg --size 50g datasudo mkfs.ext4 /dev/data/pg
bashon the server
# physical and logical volumessudo pvssudo lvs# add 20 GiB to the volume and its file systemsudo lvextend --resizefs --size +20g data/pg

With --resizefs, lvextend also grows the file system straight away, if it supports that; without it, only the volume grows. The space comes from the free space of the data group.

Section sources

the section is written from these pages

System logs

Linux logs are text files in /var/log plus the systemd journal. In Ubuntu, the rsyslog service writes service and kernel messages to /var/log/syslog. Debian 12 and later do not install rsyslog by default, and messages are kept only in the systemd journal, which you read with journalctl.

Where things are

PathContents
/var/log/syslogService and kernel messages, if rsyslog is installed
/var/log/journal/The systemd journal in binary format; read with journalctl
/var/log/mail.logMail service messages, if rsyslog is installed
/var/log/dpkg.logPackage installation and removal
*.1, *.2.gzEarlier copies of logs after rotation

The rsyslog rules are in /etc/rsyslog.conf and in the files of the /etc/rsyslog.d/ directory. A rule such as *.* /var/log/syslog means “messages from any source at any priority go to syslog”. Put your own rules in separate files in /etc/rsyslog.d/ rather than changing the distribution’s files.

journalctl -e shows the latest systemd journal entries, and journalctl -ef shows new ones as they are written. Filtering by service and by time is covered in the systemd reference, in the “Journal and journalctl” section.

Reading and searching

bashon the server
# new lines as they are writtensudo tail -f /var/log/syslog# the same for the systemd journaljournalctl -ef

To search a log, use grep; to count repeats, use sort and uniq. The commands and recipes are in the “Text processing: grep, sed, awk” section.

Kernel messages: dmesg

dmesg shows the kernel ring buffer: disk and network card detection, I/O errors and other kernel messages since boot.

bashon the server
# with human-readable timestampssudo dmesg -T# errors and warnings onlysudo dmesg -l err,warn# wait for new messagessudo dmesg -w

The time shown by -T can be inaccurate, for example after the machine has been suspended.

Rotation: logrotate

So that logs do not fill the disk, logrotate rotates them: on a schedule it renames the current file, starts a new one, compresses old copies and deletes the oldest. It usually runs once a day, through cron or a systemd timer. The general settings are in /etc/logrotate.conf; its include directive pulls in the directory with per-program rules, which in Ubuntu and Debian is /etc/logrotate.d/.

text/etc/logrotate.d/myapp
/var/log/myapp/*.log {    daily    rotate 14    compress    delaycompress    missingok    notifempty    postrotate        systemctl reload myapp.service    endscript}
DirectiveWhat it does
daily, weekly, monthlyHow often to rotate
size 100MRotate when the file exceeds the given size
rotate 14How many old copies to keep; older ones are deleted
compressCompress old copies with gzip
delaycompressCompress a copy at the next rotation, since the program may still be writing to it
missingokDo not treat a missing log as an error
notifemptyDo not rotate an empty file
copytruncateCopy the file and truncate it, if the program cannot reopen it
postrotate … endscriptA command to run after rotation, usually to ask the service to open a new file
bashon the server
# what logrotate would do, without changing anythingsudo logrotate -d /etc/logrotate.d/myapp# rotate nowsudo logrotate -f /etc/logrotate.d/myapp

Section sources

the section is written from these pages

The cron scheduler

cron runs commands on a schedule: each crontab line is a cron job made up of five time fields and a command. Edit your own crontab with crontab -e. A job runs as the crontab’s owner with a minimal environment, so use full paths in commands.

Line format

textcrontab -e
# minute hour day-of-month month day-of-week command30 2 * * * /usr/local/bin/backup.sh
FieldValues
Minute0–59
Hour0–23
Day of month1–31
Month1–12 or jan, feb …
Day of week0–7 (0 and 7 are Sunday) or sun, mon …

* means any value, 1-5 a range, 1,15 a list and */10 every tenth. If both the day of month and the day of week are set, the job runs when either field matches.

ScheduleLine
Every 5 minutes*/5 * * * *
Every hour at 15 minutes past15 * * * *
Every day at 02:3030 2 * * *
On weekdays at 09:000 9 * * 1-5
On the first of the month at midnight0 0 1 * *
Every Sunday at 04:055 4 * * sun
Once a day at midnight@daily
Once, when cron starts@reboot

crontab -e and crontab -l

bashon the server
# your own crontabcrontab -ecrontab -l# root’s crontabsudo crontab -e# check a file’s syntax without installing itcrontab -n mycron.txt

Crontab files are stored in /var/spool/cron/crontabs/, but you should edit them only through crontab. If the crontab command is missing, install the cron package.

System jobs: /etc/crontab and /etc/cron.d

In /etc/crontab and the files in /etc/cron.d/, there is an extra field between the time and the command: the user. Files in /etc/cron.d/ must be owned by root and must not be writable by the group or others. A file name may contain only letters, digits, _ and -: cron skips a file with a dot in its name.

text/etc/cron.d/myapp
SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binMAILTO=""*/10 * * * * www-data /usr/local/bin/myapp-sync

The scripts in /etc/cron.daily/, /etc/cron.weekly/ and /etc/cron.monthly/ are run by run-parts on the schedule in /etc/crontab; if anacron is installed, it runs these jobs instead.

Environment and output

cron sets SHELL, LOGNAME and HOME itself, and a job has neither the variables from your profile nor your PATH. So write full paths to programs, or set PATH on a line at the top of the crontab. Variables are not expanded on such lines: PATH=$HOME/bin:$PATH will not work. cron turns a % sign in a command into a newline, so escape it: \%.

cron mails a job’s output to the crontab’s owner or to the address in MAILTO; MAILTO="" turns the mail off. On a server without mail, redirect the output to a file:

textcrontab -e
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1

Did the job run

By default, cron logs the start of every job to the system log; the cron daemon’s -L option sets what else to log. Job processes appear in the log and in ps under the name CRON. In Debian without rsyslog, these entries are in the systemd journal.

bashon the server, Ubuntu
grep CRON /var/log/syslog

For a comparison of cron with systemd timers, see the systemd reference, in the “Timers and comparison with cron” section.

Section sources

the section is written from these pages

Common errors and diagnostics

Work through diagnosis from resources to the program: first load, memory and disk space, then kernel messages and the service log. Texts such as No space left on device are the standard descriptions of errno error codes, printed by all sorts of programs.

  1. uptime — load average over 1, 5 and 15 minutes; compare it with the number of processors (nproc).
  2. free -h — memory: look at the available column, not free.
  3. df -h and df -i — space and inodes on filesystems.
  4. top — which processes use the CPU and memory.
  5. sudo dmesg -T and the service log — see the “System logs” section and the systemd reference.

No space left on device

Cause: the filesystem has run out of space, or of inodes if it holds a very large number of small files. Space is also held by a deleted file that a process still has open.

bashcheck
df -hdf -i# largest directories in /varsudo du -xh --max-depth=1 /var | sort -h# deleted but still open filessudo lsof +L1
  • Delete or compress old logs and archives; set up rotation in logrotate — see the “System logs” section.
  • If a deleted file is holding the space, restart the process in the PID column of the lsof output.
  • If inodes have run out, find the directory with a huge number of files: sudo du --inodes -x /var | sort -n.

Permission denied

Cause: the user lacks the required permission on the file itself or on one of the directories in its path. To read a file you need r on the file and x on every directory above it; to create a file you need w and x on the directory.

bashcheck
idls -l /srv/app/config.env# permissions of each directory in the pathls -ld /srv /srv/app
  • Give the service’s group access: sudo chgrp www-data /srv/app/config.env and sudo chmod 640 /srv/app/config.env.
  • If the action is an administrator’s, run the command with sudo — see “Access and initial setup”.
  • Don’t set chmod 777: it opens the file to every user.

Address already in use

Cause: another process already holds the port — often a previous instance of the same program.

bashcheck
sudo lsof -iTCP:8080 -sTCP:LISTEN

Fix: stop the process that holds the port (kill PID, see “Processes and signals”) or configure the program to use a free port. To see all listening ports at once, run sudo ss -tulpn — see “Networking: ip, ss and configuration”.

A process suddenly terminated: out of memory

Cause: memory is exhausted and the kernel killed a process to free some. The kernel picks the victim by its OOM (out of memory) score: in top this is the OOMs column, from 0 (never) to 1000 (always).

bashcheck
free -h# processes by memory: press M in toptop# kernel messages about memory shortagesudo dmesg -T | grep -iE 'oom|out of memory'
textexample output of free -h
               total        used        free      shared  buff/cache   availableMem:           3.8Gi       3.3Gi       140Mi        12Mi       610Mi       520MiSwap:             0B          0B          0B

A small free value does not by itself mean a shortage: part of the memory is used by the cache (buff/cache), which the kernel can release. The available column shows how much memory is available to new programs. If available is low too, find the process that took the memory and limit it through the application’s settings or the service’s resource controls — see the systemd reference, section “Resources and cgroups”.

High load: load average

Load average is the average number of processes that are running or waiting for a CPU; on Linux this includes processes waiting for I/O (state D). A load of 4 on a four-CPU machine means full utilisation; on a single-CPU machine it means a queue.

bashcheck
uptimenproc# what uses the CPU: press P in toptop
textexample output
 14:07:12 up 12 days,  3:35,  2 users,  load average: 3.91, 2.80, 1.95

If the load is high while the CPU is idle and the wa value (I/O wait) on the top CPU line is large, processes are waiting for the disk: check dmesg for disk errors.

Too many open files

Cause: the process has hit its open-file limit (RLIMIT_NOFILE) — usually a service with many connections.

bashcheck
# approximate number of open files of process 1234sudo lsof -p 1234 | wc -l

Fix: raise the service’s limit (LimitNOFILE in its unit — see the systemd reference) and check whether the program forgets to close files and connections.

Section sources

the section is written from these pages

Versions and what’s new

This reference covers Ubuntu Server 26.04 LTS and Debian 13 (trixie). The latest releases are Ubuntu 26.04.1 of 27 August 2026 and Debian 13.7 of 12 September 2026. Ubuntu LTS releases come out every two years and receive 5 years of standard support; Debian supports a release for 5 years.

ReleaseReleasedStandard support untilExtended until
Ubuntu 26.04 LTS — covered hereApril 2026May 2031May 2036 (Ubuntu Pro)
Ubuntu 26.10October 2026July 2027—
Ubuntu 24.04 LTSApril 2024May 2029May 2034 (Ubuntu Pro)
Ubuntu 22.04 LTSApril 2022May 2027May 2032 (Ubuntu Pro)
Ubuntu 20.04 LTSApril 2020May 2025, endedMay 2030 (Ubuntu Pro)
Debian 13 trixie — covered here9 August 20259 August 202830 June 2030 (LTS)
Debian 12 bookworm10 June 202311 July 2026, ended30 June 2028 (LTS)

Standard support for Ubuntu LTS means security fixes for packages in the Main component. Universe packages receive them only through an Ubuntu Pro subscription, which is free for personal use on five machines. For Debian, the first 3 years are full release support and the next 2 years are Long Term Support (LTS).

The Linux kernel

Ubuntu 26.04 LTS ships kernel 7.0. Kernel releases on kernel.org as of 8 November 2026:

kernel.org branchVersionDate
mainline7.318 October 2026
stable7.3.3, 7.2.156 November 2026
longterm6.18, 6.12, 6.6, 6.1, 5.15, 5.10fixes on 6 November 2026

What changed in Ubuntu 26.04 LTS

  • Access and initial setup: sudo is now sudo-rs; the previous implementation is available as sudo.ws. OpenSSH 10.2: ssh.service gained a second name, sshd.service.
  • Text processing: the core utilities come from rust-coreutils; the GNU versions are called with the gnu prefix, while cp, mv and rm remain GNU for now.
  • Packages: APT 3. The new dependency solver is used when the classic one finds no solution. apt show and apt list gained a pager, and apt gained an operation history (apt history-list, apt history-undo).
  • Networking: Netplan 1.2. At boot the system waits for link-local addresses and for at least one interface with a routable address.
  • Filesystem and paths: /tmp is a tmpfs filesystem by default.
  • What Linux is and how it is structured: kernel 7.0 instead of 6.8, crash dumps on kernel failure are enabled by default, and Dracut builds the initramfs instead of initramfs-tools.

Deprecated and removed

  • cgroup v1 support (the legacy and hybrid hierarchies) was removed in 26.04 along with the move to systemd 259.
  • System V service scripts: 26.04 is the last release that supports them; convert them to systemd units.
  • apt-key was removed: signatures are verified directly through gpgv; for how to add repository keys, see “Packages: apt and dnf”.
  • The DSA algorithm was removed from OpenSSH, and DSA host keys are no longer generated.
  • pkcon was removed in favour of pkgcli.
  • The sudo-ldap package was removed: configure LDAP authentication through PAM.

How to upgrade

Within a release, the system is updated with the usual apt update and apt upgrade. For how to move to the next Ubuntu release and the checks to make beforehand, see “Packages: apt and dnf”.

Section sources

the section is written from these pages

End of the reference

What changed

revision history · 4 entries

Every edit is saved as a revision: a snapshot of the reference, the reason and a summary of changes. The published version changes only after the same checks as at creation.

  1. Manual edit

    reason: manual edit
  2. Manual edit

    reason: manual edit
  3. Manual edit

    reason: manual edit
  4. Reference updated

Weekly check

How the reference is checked

Once a week — and right after news of a release or a vulnerability — the reference is checked in three steps.

  1. 1. Freshness

    Sections are compared with the release notes and changelogs from the official sources and with the topic’s news.

  2. 2. Errors

    Every section is read again: wrong facts, outdated APIs and flags, broken examples.

  3. 3. Links — by an HTTP request

    Every source link must respond. A broken link is a reason to recheck the section.

No findings — only the date changes. Findings — only the affected sections are rewritten, and they appear in “What changed”. A new version replaces the published one only after passing the same checks as at creation.

Statuses

Verified
no findings
Updated
sections rewritten, edits are listed
Rechecking
while the check runs, the previous version stays open
Needs review
disputed points: the verified version is shown, editors review

Last check

18 Nov · Check · updated · no findings

Found an error in the reference?

On the topic

tracks, news and other references
The whole “Linux” topic
13 sections
Another reference · DevOps & cloud

Docker

Verified 31 Oct
All references · 61