1. Linux, kernel and distributions #
What we call Linux.
A kernel and an ecosystem #
Strictly speaking, Linux is a kernel: the program that manages the processor, memory, disks and network, and arbitrates programs' access to the hardware. What you install on a server is a distribution: the kernel, plus the GNU tools, a package manager, systemd and an update policy.
Programs run in user space; only the kernel runs in kernel space. They communicate through system calls (open, read, fork, connect...), which can be observed with strace.
Distribution families #
| Family | Distributions | Packages | Typical use |
|---|---|---|---|
| Debian | Debian, Ubuntu | .deb, apt | Web servers, cloud, workstations |
| Red Hat | RHEL, Rocky Linux, AlmaLinux, Fedora | .rpm, dnf | Enterprise, long-term support, certifications |
| SUSE | SLES, openSUSE | .rpm, zypper | Enterprise, SAP |
| Lightweight | Alpine | apk | Container images |
Good practice: For a server, choose a distribution with long-term support (Ubuntu LTS, Debian stable, RHEL or its clones): 5 to 10 years of security fixes.
Identifying the system #
cat /etc/os-release # distribution et version
uname -r # version du noyau
hostnamectl # nom, OS, noyau, architecture, virtualisation
lscpu ; free -h ; lsblk # CPU, mémoire, disques2. Booting #
From firmware to the login prompt.
The steps #
- The firmware (UEFI) initializes the hardware and launches the bootloader from the EFI partition.
- GRUB offers the installed kernels and passes them options (
/proc/cmdline). - The kernel decompresses itself, detects the hardware and mounts the initramfs, a mini-system that loads the drivers needed to access the root disk (LVM, RAID, encryption).
- The root is mounted and the kernel starts systemd, process number 1 (PID 1).
- systemd reaches the default target:
multi-user.targeton a server,graphical.targeton a workstation.
Inspecting the boot #
systemctl get-default # cible par défaut
systemd-analyze # durée totale du démarrage
systemd-analyze blame | head # services les plus lents
journalctl -b -p err # erreurs du démarrage courant
journalctl --list-boots # démarrages précédents
dmesg -T | tail # messages du noyauRescue mode: To repair a server that no longer boots, addsystemd.unit=rescue.target(oremergency.target) to the kernel line in GRUB: you get a minimal root shell.
3. The directory tree (FHS) #
Where things are.
Directories to know #
| Directory | Content |
|---|---|
/etc | System and service configuration (text) |
/var | Variable data: /var/log (logs), /var/lib (databases, state), /var/cache |
/home, /root | Home directories of users and root |
/usr | Programs and libraries installed by packages (/usr/bin, /usr/lib) |
/opt, /usr/local | Software installed outside the package manager |
/tmp | Temporary files, often cleared at reboot |
/boot | Kernels, initramfs, GRUB configuration |
/dev | Device files (/dev/sda, /dev/null) |
/proc, /sys | Virtual file systems exposed by the kernel |
/srv | Served data (websites, FTP) |
Good practice: Back up at least/etc,/home,/root,/srvand the application data in/var/lib: the rest can be reinstalled from packages.
Everything is a file #
Linux exposes almost everything as files: devices, kernel information, parameters. You read the system state with cat and often change it with echo or sysctl.
cat /proc/cpuinfo | grep 'model name' | head -1
cat /proc/meminfo | head -3
cat /proc/loadavg
cat /sys/class/net/eth0/address # adresse MAC
sysctl net.ipv4.ip_forward # paramètre noyau
ls -l /proc/$$/fd # descripteurs ouverts par le shell courant4. Finding documentation #
Finding the answer on the machine.
Built-in help #
man 5 fstab # section 5 : formats de fichiers
man -k partition # chercher une page de manuel
ssh --help | less # aide courte
help cd # commandes internes de bash
type ls ; which -a python3
apropos firewall| man section | Content |
|---|---|
| 1 | User commands |
| 5 | Configuration files |
| 8 | Administration commands |
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Linux vs Unix: the complete guide to commands and distributions
Understand the differences between Linux and Unix, explore distributions (server, desktop, lightw...
Linux administration best practices
Checklist for administering Linux servers: accounts and sudo, SSH, updates, systemd services, sto...
Packages, systemd services, logs and scheduled tasks
Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...
Storage on Linux: disks, partitions, file systems and LVM
Administer Linux storage: lsblk and blkid, GPT partitioning, ext4 and XFS, mounting and /etc/fsta...
Users, groups, sudo and permissions on Linux
Manage Linux accounts (useradd, usermod, passwd, chage), groups, sudo and visudo, rwx and octal p...
Networking on Linux: configuration, diagnosis, firewall and SSH
Configure and troubleshoot Linux networking: ip, ss, netplan and NetworkManager, DNS, layered dia...
Linux server security and hardening
Harden a Linux server: least privilege, updates, secure SSH, firewall, fail2ban, SELinux and AppA...
Backup, monitoring and troubleshooting of a Linux server
Operate a Linux server day to day: 3-2-1 backup strategy with rsync, tar, LVM snapshots and resti...
The Bash shell and files: navigation, redirections, pipes and text processing
Master the Linux command line: paths, file handling, wildcards, redirections, pipes, searching wi...