Linux Operating Systems Fundamentals · Lessons 5–6
Linux Operating Systems Fundamentals Study Guide: Lessons 5–6
Review the boot process, GRUB, systemd and SysVinit, shutdown, virtualization, the Linux GUI, accessibility, localization, time, and printing for Lessons 5–6.
How to use this guide
This guide combines the Lessons 5–6 chapter material. Lesson 5 follows a Linux system from power-on to a running set of services and back down again. Lesson 6 covers what users see on top of that running system: the graphical desktop, accessibility, localization, time, and printing.
Study in this order:
- Learn the vocabulary, commands, options, and file paths in the lesson summaries.
- Explain the key comparisons and decision rules in your own words.
- Practice the commands in a lab VM, then revisit the high-yield distinctions across both lessons.
Many questions hinge on one exact subcommand, option, or path. Learn the real name and be ready to reject look-alikes that don’t exist, such as systemd set-default, systemctl set-def, /etc/init-d, or XFree86 --query.
The ideas that connect Lessons 5 and 6
- Lesson 5 — getting the system running: firmware → boot loader (GRUB) → kernel → init system (systemd or SysVinit) → services and targets. It also covers stopping the system, warning users, and running Linux as a virtual guest.
- Lesson 6 — making the system usable: the graphical stack (display server, window manager, desktop environment), accessibility, remote desktops, locales and character sets, time zones and clocks, and printing with CUPS.
The connection is the graphical target. systemd’s graphical.target (runlevel 5) is what starts the display manager, and switching to multi-user.target (runlevel 3) is how you stop the GUI to fix X configuration.
Lesson 5 — Booting, Initializing, and Virtualizing Linux
The four boot stages
- Firmware (BIOS or UEFI) runs the Power-On Self-Test (POST) and finds a boot loader.
- Boot loader (GRUB) chooses the kernel and its options.
- Kernel loads, mounts the root filesystem (with help from the
initrd/initramfs), and starts the init program. - Initialization (systemd or SysVinit, PID 1) starts the services.
Reading boot messages
- The kernel stores its messages in the kernel ring buffer, a fixed-size circular buffer in memory.
dmesgdisplays the kernel ring buffer and is the command to use when troubleshooting the boot process. Many systems also save it to/var/log/dmesg.- On systemd systems,
journalctl -bshows messages from the current boot (-kfor kernel messages only). - Some distributions also write
/var/log/bootor/var/log/boot.log.
dmesg | less
dmesg | grep -i sda
sudo journalctl -b
Firmware: BIOS and UEFI
| Feature | BIOS | UEFI |
|---|---|---|
| Where the boot loader lives | Master boot record (MBR), the first disk sector | .efi files on the FAT-formatted EFI System Partition (ESP) |
| Size limit | One sector | None in practice |
| Linux mount point | None | /boot/efi |
- Chainloading lets one boot loader hand off to another, which is how one menu offers several operating systems.
- Secure Boot and shim: on UEFI systems with Secure Boot, the firmware loads the signed
shim.efifirst (the default), and shim then loadsgrubx64.efi, the GRUB boot loader. ls /sys/firmware/efisucceeds only on a UEFI-booted system.
GRUB Legacy
- Configuration file:
/boot/grub/menu.lst(or/boot/grub/grub.confon Red Hat systems). - Counts disks and partitions from 0:
(hd0,0)is the first partition on the first disk. - Install it once with
grub-install /dev/sda; it rereads its configuration file on every boot.
| Command | Purpose |
|---|---|
default, timeout |
Default entry (from 0) and seconds to wait |
title |
Menu text; starts each OS section |
root |
Partition holding /boot |
kernel |
Kernel image plus kernel parameters |
initrd |
Initial RAM disk with boot-time drivers |
rootnoverify |
Marks a partition holding a non-Linux kernel, such as Windows. GRUB Legacy only; GRUB 2 doesn’t use it. |
chainloader +1 |
Hand off to the boot loader in that partition’s first sector |
title Windows
rootnoverify (hd0,0)
chainloader +1
GRUB 2
- The generated file is
grub.cfg(/boot/grub/,/boot/grub2/, or/boot/efi/EFI/<distro>/). Don’t edit it. - Edit
/etc/default/grub(settings such asGRUB_TIMEOUTandGRUB_CMDLINE_LINUX) or the scripts in/etc/grub.d/, then regenerate the file. - After changing
/etc/default/grub, rungrub-mkconfig(Red Hat:grub2-mkconfig). It writes to STDOUT unless you add-oto name the output file. Ubuntu’supdate-grubdoes the same thing. - Partitions count from 1:
(hd0,1)is the first partition of the first disk. - Entries use
menuentry "Name" { ... },set root=,linux, andinitrd(orlinuxefi/initrdefion UEFI).
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Using the menu: hold Shift as GRUB takes control to display a hidden menu (tap Esc on many UEFI systems). Press E to edit an entry for one boot, C for the GRUB command line, and Ctrl+X (GRUB 2) or B (Legacy) to boot the edited entry.
Kernel boot parameters
Add these to the end of the kernel (Legacy) or linux (GRUB 2) line for one boot:
| Parameter | Effect |
|---|---|
ro |
Initially mount the root partition read-only (the default); it’s remounted read-write later in the boot |
rw |
Mount root read-write from the start |
root= |
Choose the root filesystem |
single (or S, 1) |
Boot into single-user mode, without launching the usual daemons |
init=/bin/bash |
Run a different program instead of /sbin/init |
systemd.unit=rescue.target |
Boot a systemd system into a specific target |
selinux=0 |
Disable SELinux for this boot |
systemd units and unit files
- A unit is anything systemd manages, named
name.type, such assshd.serviceormulti-user.target. systemctl list-unitslists the units systemd has loaded; add--type=servicefor services only.systemctl list-unit-fileslists installed unit files and whether they’re enabled.- Unit file priority, highest first:
/etc/systemd/system/→/run/systemd/system/→/usr/lib/systemd/system/.
| Section | Key directives |
|---|---|
[Unit] |
Description, After/Before (order only), Requires, Wants, Conflicts |
[Service] |
ExecStart (the program to run when the service starts), ExecStop, ExecReload, Type, Restart |
[Install] |
WantedBy (the target that pulls the unit in when it’s enabled) |
systemd watches the process ID (PID) of the ExecStart program to tell whether the service has crashed.
[Service]
ExecStart=/usr/sbin/sshd -D $OPTIONS
Restart=on-failure
[Install]
WantedBy=multi-user.target
After editing a unit file, run systemctl daemon-reload, then restart the service.
Managing services with systemctl
| Command | What it does |
|---|---|
start / stop / restart |
Change the service now |
enable / disable |
Start (or don’t start) the service at the next boot; --now also starts or stops it immediately |
reload |
The service rereads its own configuration file |
daemon-reload |
systemd rereads its unit files |
mask / unmask |
Block, or unblock, a unit from starting at all |
status, is-active, is-enabled |
Check state |
The command is always systemctl, not systemd.
Targets
default.targetis the unit a systemd system boots into; it’s a link to the real target, which then starts other units based on dependencies.
| Target | Meaning | Runlevel |
|---|---|---|
poweroff.target |
Shut down | 0 |
rescue.target |
Single-user maintenance, local filesystems, no network | 1 |
multi-user.target |
Multi-user, networking, text only | 3 |
graphical.target |
Multi-user with a GUI | 5 |
reboot.target |
Reboot | 6 |
emergency.target |
Root filesystem read-only, root only | — |
systemctl get-default # display the default target
sudo systemctl set-default multi-user.target # set the default target (next boot)
sudo systemctl isolate multi-user.target # switch targets (runlevels) now
get-defaultdisplays the boot target,set-defaultchanges it, andisolateswitches to another target immediately.
SysVinit and runlevels
/etc/init.d/stores the startup and shutdown scripts for each service (sometimes linked from/etc/rc.d/init.d/)./etc/rc.d/rcN.d/holdsS##name(start) andK##name(kill) links for runlevel N./etc/inittabsets the default runlevel (id:5:initdefault:).telinittellsinitto change runlevels, andtelinit qmakes it reload/etc/inittabwithout a reboot.init Nandtelinit Nare equivalent.runlevelprints the previous and current runlevels.service NAME start|stop|statusruns a script in/etc/init.d/.
Stopping the system
| Command | Effect |
|---|---|
halt |
Stops all processes and the CPU immediately; the power may stay on |
poweroff |
Stops everything and turns the power off |
reboot |
Stops everything and restarts |
shutdown |
Scheduled and flexible: -h/-H halt, -P power off, -r reboot, -c cancels a pending shutdown |
sudo shutdown -r +10 "Rebooting for updates. Save your work."
sudo shutdown -h now
sudo shutdown -c
- Shutdown sends
SIGTERMto processes, including the X server, so they can exit cleanly and close their files.SIGKILL(kill -9) can’t be caught and gives no chance to clean up.
Notifying users
| Tool or file | When users see it |
|---|---|
wall |
Sends a message to all logged-in users’ terminals (type the message, then Ctrl+D) |
mesg n / mesg y |
Refuse or accept wall messages |
/etc/issue / /etc/issue.net |
Before a local / remote login |
/etc/motd |
After login (message of the day) |
notify-send |
Desktop pop-up for GUI users |
Virtualization, containers, and cloud
- Type 1 hypervisors (KVM, Xen, Hyper-V, ESXi) run on the hardware; Type 2 (VirtualBox, VMware Workstation Player) run on a host OS.
- VMs can be created from scratch, as a clone, from a template, or imported as OVF/OVA.
- After cloning, regenerate unique identifiers such as the host name, MAC address, and
/etc/machine-id. - CPU flags
vmx(Intel) orsvm(AMD) show hardware virtualization support; thehypervisorflag means you’re already inside a VM. - Containers share the host kernel; VMs run a full guest OS. Docker (application) and LXC (OS) are common container engines.
- IaaS, PaaS, SaaS go from most to least customer control. cloud-init configures cloud instances at first boot.
Lesson 5 terms to know
POST, BIOS, UEFI, MBR, ESP, /boot/efi, shim.efi, grubx64.efi, chainloading, dmesg, kernel ring buffer, journalctl -b, GRUB Legacy, menu.lst, rootnoverify, GRUB 2, grub.cfg, /etc/default/grub, grub-mkconfig -o, update-grub, Shift, ro, single, initrd, initramfs, systemd, unit, ExecStart, WantedBy, systemctl list-units, enable, daemon-reload, default.target, get-default, set-default, isolate, multi-user.target, graphical.target, rescue.target, SysVinit, /etc/inittab, /etc/init.d, telinit, runlevel, service, halt, shutdown -c, SIGTERM, SIGKILL, wall, mesg, /etc/motd, hypervisor, clone, template, OVF, machine ID, container, IaaS, and cloud-init.
Lesson 6 — Configuring the GUI, Localization, and Printing
What the GUI is for
- A desktop computer is used by one person or a small number of people for everyday productivity tasks, such as working with a spreadsheet or browsing the web.
- The GNU toolset and the X Window System are core Unix tools that the normal Linux system relies on. Startup scripts and Apple’s Aqua interface are not.
- Not every Linux program is graphical. Some web browsers are text-mode, such as Lynx, which runs in a terminal.
- You can launch a GUI program from the desktop’s menus or by typing its name in a terminal emulator.
The layers of a Linux GUI
- Display server carries requests between programs and the hardware (X.Org or Wayland).
- Compositor combines all windows into one screen image.
- Window manager places, sizes, and decorates windows (Mutter, KWin, Muffin, Marco, Xfwm).
- Desktop environment provides the overall look and feel (GNOME, KDE Plasma, Cinnamon, MATE, Xfce).
X11: XFree86 and X.Org
- Linux first used XFree86; most distributions moved to X.Org (X version 11) in 2004.
- Modern X.Org auto-detects hardware, so a configuration file often doesn’t exist.
- To create a configuration file you can edit, stop the GUI and run
Xorg -configureas root (orXFree86 -configurewith XFree86). The server queries the hardware and writes a new file. ~/.xsessionlists commands for starting X clients. It replaces the system-wide default session or window manager, so it must launch the window manager or desktop you want.~/.xsession-errorslogs problems with the session.
xorg.conf section |
Purpose |
|---|---|
InputDevice |
Keyboard and mouse |
Monitor |
Monitor settings |
Device |
Video card |
Screen |
Binds one video card to one monitor, with resolution and color depth |
Module |
Modules to load; Disable keeps a default module from loading, and Load for the same module takes precedence |
Files |
Paths to fonts, modules, and keyboard layouts |
ServerLayout |
Ties input and output devices into one session |
Keyboard options in X:
| Option | Sets |
|---|---|
XkbModel |
The keyboard model, such as pc105 for a 105-key keyboard |
XkbLayout |
The keyboard layout (language), such as us or gb |
Wayland
- Wayland is the modern replacement for X. Its compositor is the display server, and it isolates programs from one another for better security.
- XWayland runs older X11 programs in a Wayland session.
echo $XDG_SESSION_TYPEprintswaylandorx11.
Desktop environments
| GNOME Shell | KDE Plasma | Cinnamon | MATE | Xfce | |
|---|---|---|---|---|---|
| Display manager | GDM | SDDM | LightDM | LightDM | LightDM |
| File manager | Files (Nautilus) | Dolphin | Nemo | Caja | Thunar |
| Window manager | Mutter | KWin | Muffin | Marco | Xfwm |
- KDE Plasma is built on the Qt widget set (GUI library). GNOME uses GTK.
- Linux file managers include Dolphin and Thunar. Thunderbird is an email client and Apache is a web server.
- A display manager provides the graphical login. XDMCP lets a display manager offer logins to remote X terminals, but it uses no compression and no encryption, so it’s normally disabled.
Accessibility
| Need | Tool or setting |
|---|---|
| Screen reader | Orca (GNOME) |
| Magnifier | KMag (kmag) in KDE; Zoom in other desktops |
| High-contrast theme | GNOME control center Appearance section (or Universal Access) |
| Braille display | brltty; native kernel support requires kernel 2.6.26 or later |
| Hearing | Visual alerts flash the screen instead of beeping |
| Motor | Sticky keys, slow keys, bounce keys, mouse keys, on-screen keyboard |
Remote GUI access
| Method | Port | Encrypted? |
|---|---|---|
X11 forwarding (ssh -X) |
22 | Yes, through SSH |
Direct X11 (xhost + DISPLAY) |
6000+ | No |
| XDMCP | 177 | No (and no compression) |
| VNC | 5900 + display | No by default; tunnel through SSH |
| Xrdp (RDP) | 3389 | Yes, TLS |
| NX / X2Go | 22 | Yes, SSH |
| SPICE | — | Optional TLS; built for VM consoles |
Localization: character sets
| Character set | Key facts |
|---|---|
| ASCII | 7 bits, 128 characters, English only |
| ISO-8859 | 8-bit sets for groups of languages |
| Unicode | One code point for every character in every alphabet, stored with single-byte or multiple-byte encodings |
| UTF-8 | Unicode in 1–4 bytes; the Linux standard |
| UTF-16 | Unicode in 2 or 4 bytes |
Locales
- A locale is written
language_COUNTRY.charset, such asen_US.UTF-8. - Precedence:
LC_ALLoverrides everyLC_*variable, which overrideLANG. localeshows the current settings;locale -alists installed locales.export LANG=en_GB.UTF-8changes the locale for the current session only.~/.bashrcruns with every interactive Bash shell, so put personalexportlines there to make them permanent.localectl set-localechanges the system-wide locale on systemd systems.
Time zones and clocks
tzselectwalks through a menu to find a time zone and prints the zone name, which can be used in scripts to set the zone./etc/localtimeis a link to a binary file in/usr/share/zoneinfo/./etc/timezone(Debian) is a text file with the zone name.TZ=Europe/London dateshows the time in another zone for one command.hwclock --systohc/--hctosyscopy the time between the system clock and the hardware clock.timedatectl set-timezone America/Chicagosets the zone on systemd systems.
Printing with CUPS
- CUPS queues and filters print jobs. Its web interface is http://localhost:631/.
lprsubmits a job,lpqshows a queue,lprmorcancelremoves a job.cupsdisablestops printing but keeps queuing jobs;cupsrejectstops the queue from accepting new jobs.
Lesson 6 terms to know
desktop, GNU toolset, X Window System, Lynx, display server, compositor, window manager, desktop environment, XFree86, X.Org, Xorg -configure, XFree86 -configure, xorg.conf, Screen, Module, Disable, XkbModel, XkbLayout, ~/.xsession, ~/.xsession-errors, Wayland, XWayland, GNOME, KDE Plasma, Qt, Dolphin, Thunar, display manager, XDMCP, Orca, kmag, Appearance, high contrast, brltty, 2.6.26, ssh -X, VNC, Xrdp, SPICE, ASCII, Unicode, UTF-8, locale, LANG, LC_ALL, ~/.bashrc, localectl, tzselect, /etc/localtime, hwclock, timedatectl, CUPS, lpr, lpq, lprm, cupsdisable, and cupsreject.
Course Notes