Based on the Linux Master 2 exam syllabusReport an error
/etc/default/grub, and you don't edit grub.cfg directly.3 = text, 5 = GUI. 1. Power applied
▼
2. Firmware (BIOS or UEFI) POST — hardware self-check
▼ Chooses the device to boot from
3. Bootloader (GRUB2) Finds the kernel and loads it into memory
▼
4. Kernel load Initializes the hardware
▼
5. initramfs A temporary toolset for mounting the root file system
▼
6. init / systemd (PID 1) Starts services → login screeninit, and now it's mostly systemd.The files read during stages 3 to 5 are all gathered in /boot. That is why /boot is often split off as its own partition.
$ ls /boot
config-5.14.0-362.8.1.el9_3.x86_64
efi
grub2
initramfs-5.14.0-362.8.1.el9_3.x86_64.img
System.map-5.14.0-362.8.1.el9_3.x86_64
vmlinuz-5.14.0-362.8.1.el9_3.x86_64| File | What it is |
|---|---|
vmlinuz-version | The kernel itself (a compressed executable image). This is the file the bootloader loads into memory |
initramfs-version.img | The temporary file system of stage 5. On the Debian family it is named initrd.img-version |
config-version | The configuration used when building this kernel |
grub2/ | The bootloader's files and configuration |
dmesg command. In a systemd environment, journalctl -b shows the entire record of this boot.| Category | BIOS | UEFI |
|---|---|---|
| Appeared | Old | The modern replacement |
| Partition scheme | MBR | GPT |
| Bootloader location | The first sector of the disk (MBR) | The ESP (EFI System Partition) |
| Disk limit | 2TB | Practically none |
| Screen | Text | Graphics and mouse possible |
| Security feature | None | Secure Boot |
| Name | Description |
|---|---|
| LILO | LInux LOader. An old bootloader. After changing its configuration, you must reinstall it for it to take effect |
| GRUB (legacy) | Replaced LILO. Editable at boot time |
| GRUB2 | The current standard. Its configuration structure differs from GRUB |
The decisive difference between LILO and GRUB: with LILO you must edit
/etc/lilo.confand then write it back in with thelilocommand, but GRUB reads the configuration file as it runs, so that step isn't needed.
| File | Role | Edit directly? |
|---|---|---|
/etc/default/grub | Default timeout, default menu entry, etc. | Edit this one |
/etc/grub.d/ | Scripts that generate menu entries | Only when needed |
/boot/grub2/grub.cfg | The final configuration actually read | Don't edit directly |
# After editing /etc/default/grub, always run this to regenerate grub.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg # Red Hat family
update-grub # Debian familygrub.cfg is an auto-generated file. Even if you edit it directly, it's overwritten at the next update.GRUB_TIMEOUT (menu wait time), GRUB_DEFAULT (default selected entry).$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"| Entry | Meaning |
|---|---|
GRUB_TIMEOUT=5 | Shows the menu for 5 seconds, then boots the default entry. With 0, it doesn't wait |
GRUB_DEFAULT=saved | Uses the entry chosen last time (saved) as the default. If you write 0, it's the first entry |
GRUB_CMDLINE_LINUX | Options passed to the kernel. rhgb is the graphical boot screen, and quiet hides boot messages |
rhgb quiet and regenerate grub.cfg. Then the messages scroll across the screen as they are.grub.cfg differs by distribution and firmware. On the Debian family it's /boot/grub/grub.cfg, and on the Red Hat family booting via UEFI, depending on the version, it may be placed under /boot/efi/EFI/. Even if the path differs, the principle "don't edit it directly" is the same.There are keys you press while the GRUB menu is displayed.
| Key | Action |
|---|---|
e | Edit the selected entry (edit) |
c | Enter the GRUB command line (command) |
Ctrl+x | (GRUB2) Boot with the edited content |
On older systems and in past-exam passages, pre-GRUB2 configuration appears.
# /boot/grub/grub.conf (GRUB legacy)
default=0
timeout=5
title CentOS (2.6.32-754.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-754.el6.x86_64 ro root=/dev/sda3 rhgb quiet
initrd /initramfs-2.6.32-754.el6.x86_64.imgtitle block is one menu entry. default=0 means the first title is the default — numbering starts from 0.(hd0,0) is the first partition of the first disk. Old GRUB counts both disks and partitions from 0. As a Linux device name, it's /dev/sda1.(hd0,1).| Bootloader | Configuration file | What to do after editing |
|---|---|---|
| LILO | /etc/lilo.conf | Run the lilo command |
| GRUB legacy | /boot/grub/grub.conf | Nothing (edit the file directly) |
| GRUB2 | /etc/default/grub | grub2-mkconfig or update-grub |
The old System V runlevels expressed the system's operating mode as a number.
| Runlevel | Meaning | systemd target |
|---|---|---|
| 0 | System shutdown | poweroff.target |
| 1 | Single-user mode (recovery) | rescue.target |
| 3 | Text multi-user | multi-user.target |
| 5 | GUI multi-user | graphical.target |
| 6 | Reboot | reboot.target |
emergency.target. It's a more minimal state than rescue.target, launching a shell with only the root file system attached read-only.System V init decided the default runlevel with a single line in /etc/inittab.
id:3:initdefault:
│ │ │
│ │ └── Action — initdefault = "make it the default runlevel"
│ └───────── Runlevel
└──────────── Label of this lineid:5:initdefault:, it's graphical mode from the next boot. If you write 0 or 6 here, it shuts down right after power-on or restarts endlessly./etc/rc.d/rc3.d/. Names that start with S are Start scripts and those that start with K are Kill scripts, and they run one at a time in sequence by the number that follows./etc/inittab, a link named default.target points to the default mode.$ sudo systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.set-default does is swap one symbolic link.| What you want to do | init way | systemd way |
|---|---|---|
| Check the current runlevel | runlevel, who -r | systemctl get-default (the default) |
| Switch immediately | init 3, telinit 3 | systemctl isolate multi-user.target |
| Change from the next boot | Edit /etc/inittab | systemctl set-default … |
$ runlevel
N 5N means "there is no previous one," that is, it hasn't been changed even once since boot.isolate is for now only, set-default is from the next boot — options swapping these two are easily used as wrong answers.Runlevels 0 and 6 are invoked with everyday commands.
| Command | Action |
|---|---|
shutdown -h now | Shut down now (halt) |
shutdown -r now | Restart now (reboot) |
shutdown -h +10 | Shut down in 10 minutes. Logged-in users are notified |
shutdown -c | Cancel a scheduled shutdown (cancel) |
poweroff, halt | Shut down |
reboot | Restart |
init 0 / init 6 | Shut down / restart by changing the runlevel |
grub.cfg for GRUB2 settings" → You edit /etc/default/grub and regenerate grub.cfg with a command.lilo command for it to take effect.systemctl isolate" → It changes only for now. The default is set-default.systemctl get-default # The current default target
systemctl set-default multi-user.target # Change to boot into text mode
systemctl isolate graphical.target # Switch to GUI mode immediatelyTomorrow we tie together this week's installation, partitions, file systems, and boot on a single page.
Click a choice to reveal the answer and explanation.
Question 1
Which of the following is the correct Linux boot order?
Question 2
Which of the following is the target that boots to a graphical login screen in a systemd environment?
Question 3
Which of the following is the configuration file an administrator should edit directly when using GRUB2?
Question 4
Which of the following is the partition scheme used together with UEFI firmware?
Question 5
Which of the following pairings of a runlevel and its meaning is NOT correct?