Linux init systems & service management reference — 154 Q&A
| # | Question | Answer |
|---|---|---|
| 1 | What are the three main service management methods discussed for Linux distributions? | SysVinit (System V), systemd, and Upstart |
| 2 | _____ is the most commonly found service manager in modern Linux distributions. | systemd |
| 3 | How can you confirm the kernel uses systemd as its init program? |
# which init/sbin/init# readlink -f /sbin/init/usr/lib/systemd/systemd
|
| 4 | How can you confirm the kernel uses systemd as its init program by viewing it as a process? |
ps -p 1 |
| 5 | How do you display processes as a tree, connecting them to the init program? | pstree |
| 6 | The Process Identification Number (PID) of the service manager — the first program launched by the kernel — is _____. | 1 |
| 7 | systemd has a concept of ___, which has a name, type, and configuration file. | unit |
| 8 | How do you list all systemd units on a system? | systemctl list-units |
| 9 | What are the basic types of a systemd unit? | wants, requires, service, target, socket, timer |
| 10 | Where are unit files located? (3 locations) |
/etc/systemd/system//run/systemd/system//usr/lib/systemd/system/
|
| 11 | How would you describe a file with the following content?[Unit]Description=Multi-User SystemDocumentation=man:systemd.special(7)Requires=basic.targetConflicts=rescue.service rescue.targetAfter=basic.target rescue.service rescue.targetAllowIsolate=yes
|
This is a unit file named default.target located under /etc/systemd/system/ |
| 12 | In the SysVinit standard, predefined sets of system states are called _____. | runlevels |
| 13 | What is the purpose of SysVinit runlevel 0? | System shutdown |
| 14 | What is the purpose of SysVinit runlevel 1 (also s or single)? |
Single-user mode for maintenance, without networking |
| 15 | What is the purpose of SysVinit runlevels 2, 3, or 4? | Multi-user mode, where users can log in via console or network |
| 16 | What is the purpose of SysVinit runlevel 5? | Multi-user mode with a graphical login, equivalent to runlevel 3 plus graphics |
| 17 | What is the purpose of SysVinit runlevel 6? | System restart (reboot) |
| 18 | In SysVinit systems, the full path to the program responsible for managing runlevels and daemons is _____. | /sbin/init |
| 19 | In SysVinit, the _____ file contains the definition of runlevels and the scripts to be executed. | /etc/inittab |
| 20 | _____ is the format of an entry in the /etc/inittab file. |
id:runlevels:action:process |
| 21 | In /etc/inittab, what does the ctrlaltdel action specify? |
The process to execute when the init process receives a SIGINT signal from a Ctrl+Alt+Del keypress |
| 22 | How is the default runlevel defined in the /etc/inittab file? |
With an entry in the format id:x:initdefault: where x is the runlevel number |
| 23 | Why should the default runlevel in /etc/inittab never be set to 0 or 6? |
It would cause the system to shut down or restart immediately after booting |
| 24 | The command _____ must be run after modifying /etc/inittab to make the init process reload its configuration. |
telinit q (or telinit Q) |
| 25 | In a SysVinit system, the actual service script files are typically stored under the _____ directory. | /etc/init.d/ |
| 26 | In SysVinit, what does the first letter K in a symbolic link filename within an /etc/rcN.d/ directory indicate? |
The service should be killed (stopped) when entering that runlevel |
| 27 | In SysVinit, what does the first letter S in a symbolic link filename within an /etc/rcN.d/ directory indicate? |
The service should be started when entering that runlevel |
| 28 | Use the command _____ to display the previous and current runlevel on a SysVinit system. | runlevel |
| 29 | In the output of the runlevel command (e.g. N 3), what does the letter N signify? |
The runlevel has not changed since the last boot |
| 30 | Which command can be used to change the current runlevel to maintenance mode on a SysVinit system? | telinit 1 |
| 31 | In systemd, system resources and services are referred to as _____. |
units |
| 32 | A systemd ___ unit is a grouping of other units managed as a single unit, similar to a SysV runlevel. | target |
| 33 | What is the main command used for controlling systemd units? |
systemctl |
| 34 | What is the command to start a service named apparmor? |
systemctl start apparmor.service |
| 35 | What is the command to stop a service named apparmor? |
systemctl stop apparmor.service |
| 36 | What command shows the detailed state of the apparmor service? |
systemctl status apparmor.service |
| 37 | What systemctl command simply shows active if a unit is running, or inactive otherwise? |
systemctl is-active unit.service |
| 38 | What is the command to configure a unit to start automatically at boot? | systemctl enable unit.service |
| 39 | What is the command to prevent a unit from starting automatically at boot? | systemctl disable unit.service |
| 40 | What command verifies if a unit is configured to start with the system? | systemctl is-enabled unit.service |
| 41 | In systemd, which unit target is equivalent to SysV runlevel 3 (multi-user mode)? | multi-user.target |
| 42 | Which command is used to manually switch to a specific target? | systemctl isolate target.name |
| 43 | Instead of /etc/inittab, how can the default boot target be changed persistently in systemd? |
By modifying the symbolic link /etc/systemd/system/default.target or using systemctl set-default |
| 44 | What command allows you to view the current default boot target in systemd? |
systemctl get-default |
| 45 | What systemctl command sets multi-user.target as the default for system boot? |
systemctl set-default multi-user.target |
| 46 | In a systemd-based system, where can the configuration files for units typically be found? |
/lib/systemd/system/ |
| 47 | What command lists all available systemd units and shows if they are enabled for boot? |
systemctl list-unit-files |
| 48 | What systemd command puts the system into a low-power mode, keeping data in memory? |
systemctl suspend |
| 49 | What systemd command copies all memory data to disk before powering off, allowing the state to be restored later? |
systemctl hibernate |
| 50 | On an Upstart system, in which directory are the initialization scripts located? | /etc/init/ |
| 51 | What Upstart command lists system services and their current state? | initctl list |
| 52 | What command is used to start a service on an Upstart system? | start |
| 53 | What command is used to stop a service on an Upstart system? | stop |
| 54 | What is the primary function of the shutdown command besides powering off or rebooting? |
It notifies all logged-in users with a warning message and prevents new logins |
| 55 | If the shutdown command is run without the -h or -r options, what is the default action? |
The system will change to runlevel 1 (single-user mode) |
| 56 | What is the syntax for scheduling a shutdown in 15 minutes with a custom message? | shutdown +15 "message" |
| 57 | How can a system reboot scheduled with the shutdown command be canceled? |
shutdown -c |
| 58 | In a systemd-based system, what is the command to reboot the machine? |
systemctl reboot |
| 59 | In a systemd-based system, what is the command to power off the machine? |
systemctl poweroff |
| 60 | What command sends a message to the terminal sessions of all logged-in users? | wall |
| 61 | How can the telinit command be used to reboot a SysVinit system? |
telinit 6 — changes to runlevel 6, which reboots the system |
| 62 | If a SysV system's default runlevel in /etc/inittab is 3, but it always boots into runlevel 1, what is a probable cause? |
The kernel's parameter list may contain the parameter 1 or S |
| 63 | On systemd-based systems, /sbin/init is a symbolic link. What executable file does it point to? |
/lib/systemd/systemd |
| 64 | The _____ action in /etc/inittab will cause init to restart a process if it is terminated. |
respawn |
| 65 | A systemd _____ unit is a mount point definition in the filesystem that is mounted automatically upon access. |
automount |
| 66 | In a SysV system, what are the folders /etc/rc0.d/ through /etc/rc6.d/ used for? |
They hold symbolic links for each runlevel, pointing to scripts in /etc/init.d/ |
| 67 | In SysV, inside /etc/rc3.d/ there is a symlink called S23ntp. Where does it point? |
/etc/init.d/ntp |
| 68 | In SysV, inside /etc/rc3.d/ there is a symlink called S23ntp. What does S23 mean? |
S = Start when entering this runlevel; 23 = execution order (lower numbers start earlier) |
| 69 | How can the telinit command be used to reboot the system? |
telinit 6 |
| 70 | What will happen to the service referenced by /etc/rc1.d/K90network when the system enters runlevel 1? |
The service will be stopped — the leading K means kill (stop) |
| 71 | Using systemctl, how could a user verify if the unit sshd.service is running? |
systemctl status sshd.service or systemctl is-active sshd.service |
| 72 | In a systemd-based system, what command enables sshd.service to activate during system initialization? |
systemctl enable sshd.service (executed as root) |
| 73 | In a SysV-based system, the default runlevel in /etc/inittab is 3, but the system always starts in runlevel 1. What is the probable cause? |
The parameters 1 or S may be present in the kernel's parameter list |
| 74 | Although /sbin/init exists on systemd-based systems, it is only a symbolic link. What file does it point to? |
/lib/systemd/systemd |
| 75 | How can the default system target be verified in a systemd-based system? |
Check /etc/systemd/system/default.target (symbolic link) or run systemctl get-default |
| 76 | How can a system reboot scheduled with the shutdown command be canceled? |
shutdown -c |
| 77 | How do you list only units of type service? |
systemctl list-units --type=service |
| 78 | How do you list only units of type target? |
systemctl list-units --type=target |
| 79 | How do you use systemctl to display the content of the sshd.service unit file? |
systemctl cat sshd.service |
| 80 | How do you use systemctl to display the content of the graphical.target unit file? |
systemctl cat graphical.target |
| 81 | A ___ unit is a grouping of other units managed as a single unit — a combination of services and configurations. | target |
| 82 | A ___ unit is a common unit type for active system resources that can be initiated, interrupted, and reloaded. | service |
| 83 | How do you verify that apparmor.service is configured to start with the system? |
systemctl is-enabled apparmor.service |
| 84 | How do you manually switch to the multi-user target? |
systemctl isolate multi-user.target |
| 85 | How do you start apparmor.service? |
systemctl start apparmor.service |
| 86 | How do you check whether apparmor.service is running? |
systemctl status apparmor.service |
| 87 | How do you stop apparmor.service? |
systemctl stop apparmor.service |
| 88 | How do you enable apparmor.service? |
systemctl enable apparmor.service |
| 89 | How do you disable apparmor.service? |
systemctl disable apparmor.service |
| 90 | How do you restart apparmor.service? |
systemctl restart apparmor.service |
| 91 | Using systemctl, how could a user verify if the unit sshd.service is running? |
systemctl is-active sshd.service |
| 92 | In a systemd-based system, what command must be executed to enable sshd.service activation during system initialization? |
systemctl enable sshd.service |
| 93 | You added PasswordAuthentication no to /etc/ssh/sshd_config. Which command applies the new configuration to new connections without disconnecting existing SSH sessions? |
systemctl reload sshd |
| 94 | Which command causes systemd to re-read every service, socket, timer, mount, and target file without restarting services? |
systemctl daemon-reload |
| 95 | How do you display kernel parameters, which may include a system target override? | cat /proc/cmdline |
| 96 | What does the following output represent?BOOT_IMAGE=/vmlinuz-linux root=/dev/sda2 rw quiet splash amd_iommu=on |
These are kernel parameters — the output of cat /proc/cmdline |
| 97 | How do you boot the system to a different target, such as rescue.target, via a kernel parameter? |
In kernel parameters, add or change systemd.unit=rescue.target |
| 98 | systemd is also responsible for triggering and responding to power-related events. How do you put the system into low-power (suspend) mode? | systemctl suspend |
| 99 | Hibernation mode copies all memory data to disk so the current system state can be recovered after powering off. How do you put the system into hibernation mode? | systemctl hibernate |
| 100 | The _____ daemon is the main power manager for Linux. It allows finer adjustments to actions following power-related events, such as closing the laptop lid or low battery. | acpid |
| 101 | What is the purpose of /etc/systemd/logind.conf and /etc/systemd/logind.conf.d/? |
They define power management actions handled by systemd-logind when a daemon like acpid is not managing those events |
| 102 | In systemd, similar to SysV, the default target should never point to _____, as it corresponds to runlevel 0. | shutdown.target |
| 103 | How do you display the current default boot target? | systemctl get-default |
| 104 | How do you set the default boot target to multi-user instead of graphical? |
systemctl set-default multi-user.target |
| 105 | How do you confirm that the default target is a symbolic link? | ls -ltra /etc/systemd/system/default.target |
| 106 | How do you view logs with systemd, including kernel messages, boot messages, service logs, and application logs? | journalctl |
| 107 | With journalctl, how do you follow logs live (real-time)? |
journalctl -f |
| 108 | With journalctl, how do you view the newest entries first? |
journalctl -r |
| 109 | With journalctl, how do you show logs only for the nginx service? |
journalctl -u nginx |
| 110 | With journalctl, how do you show the last few log entries with extra detail? |
journalctl -xe |
| 111 | With journalctl, how do you show logs from only the last 10 minutes? |
journalctl --since "10min ago" |
| 112 | With journalctl, how do you show only the last 10 lines? |
journalctl -n 10 |
| 113 | With journalctl, how do you show logs from the last 1 day? |
journalctl --since -1d |
| 114 | With journalctl, how do you filter logs by process ID? |
journalctl _PID=16883 |
| 115 | Which older init system can still be found on many Linux systems? | SysV |
| 116 | In SysV, where are the service control program scripts stored? | /etc/init.d/ |
| 117 | In SysV, how do you show the status of the httpd service? |
/etc/init.d/httpd status |
| 118 | In SysV, options for controlling services are passed after the script name (e.g. /etc/init.d/httpd status). What are the other common options? |
stop, start, restart |
| 119 | _____ is the most commonly used boot target with no graphical interface. | multi-user.target |
| 120 | The unit file for the graphical target is typically located at _____. | /usr/lib/systemd/system/graphical.target |
| 121 | systemd _____ are the equivalent of SysV runlevels in modern systems. | boot targets |
| 122 | In SysV, how many runlevels are there? | 7 levels — 0 through 6 |
| 123 | Which SysV runlevel corresponds to system shutdown? | Runlevel 0 |
| 124 | Which SysV runlevel puts the system in single-user mode (maintenance), without networking? | Runlevel 1 (also s or single) |
| 125 | Which SysV runlevels correspond to multi-user mode where users can log in via console or network? | Runlevels 2, 3, or 4 (runlevel 3 is most commonly used) |
| 126 | Which SysV runlevel corresponds to multi-user graphical mode? | Runlevel 5 (equivalent to runlevel 3 plus graphical login) |
| 127 | Which SysV runlevel corresponds to system restart? | Runlevel 6 |
| 128 | In the SysVinit standard, predefined sets of system states are called _____. | runlevels |
| 129 | In SysV we have runlevels. What is the systemd equivalent of runlevels? | boot targets |
| 130 | How do you check whether the system has reached the graphical target? | systemctl status graphical.target |
| 131 | Which systemd target corresponds to single-user rescue mode? | rescue.target |
| 132 | What is one requirement for graphical.target? |
multi-user.target |
| 133 | systemctl has specific built-in targets. What are they? |
rescue, emergency, reboot, halt (stops processes and halts CPU), poweroff |
| 134 | How do you switch the system to emergency mode? | systemctl isolate emergency |
| 135 | What command checks the current runlevel on a SysV system? | runlevel |
| 136 | _____ is the format of an entry in the /etc/inittab file. |
id:runlevels:action:process |
| 137 | In SysVinit, which file contains the definition of runlevels and the scripts to be executed? | /etc/inittab |
| 138 | What command shows the default runlevel defined in /etc/inittab? |
grep "^id:" /etc/inittab — e.g. output: id:5:initdefault: |
| 139 | What does running init 3 do on a SysV system? |
Switches the system to multi-user mode (runlevel 3) |
| 140 | init 5 will switch a SysV system to _____ mode. |
Graphical (multi-user with GUI login) |
| 141 | What is the alternative command to init 5 for switching to multi-user graphical mode on a SysV system? |
telinit 5 |
| 142 | What is inside the folder /etc/rc5.d/? |
Symbolic links with special filenames (prefixed S or K) pointing to scripts in /etc/init.d/ for multi-user graphical mode |
| 143 | _____ is an open standard for computer hardware components, especially for power management. | ACPI (Advanced Configuration and Power Interface) |
| 144 | Which file do you edit to set the message of the day (shown at login)? | /etc/motd |
| 145 | How do you reboot the system safely using systemctl? |
sudo systemctl reboot |
| 146 | How do you shut down the system safely using systemctl? |
sudo systemctl poweroff |
| 147 | How do you force a system reboot using systemctl? |
sudo systemctl reboot --force |
| 148 | How do you force a system power-off using systemctl? |
sudo systemctl poweroff --force |
| 149 | How do you immediately reboot the system (simulating a power button press) using systemctl? |
sudo systemctl reboot --force --force |
| 150 | How do you immediately power off the system (simulating a power button press) using systemctl? |
sudo systemctl poweroff --force --force |
| 151 | How do you schedule a system reboot at 02:00 using the shutdown command (not systemctl)? |
sudo shutdown -r 02:00 |
| 152 | How do you reboot the system after 15 minutes using the shutdown command (not systemctl)? |
sudo shutdown -r +15 |
| 153 | How do you shut down the system after 15 minutes using the shutdown command (not systemctl)? |
sudo shutdown +15 |
| 154 | How do you reboot after 15 minutes with a broadcast wall message to all users? | sudo shutdown -r +15 'Scheduled restart to do offline maintenance' |