Study Guide - Chap6: Maintaining System Startup and Services Flashcards
(23 cards)
1- The init program may be located in which of the following directories? (Choose all that apply.)
- /etc/rc.d/
- /etc/
- /sbin/
- /usr/lib/systemd/
- /bin/
- /etc/
- /sbin/
- /bin/
The init program may exist in the /etc/, /sbin/, or /bin/ directory, depending on your distribution and its version, so therefore options B, C, and E are correct. The /etc/rc.d/ directory is used in SysVint systems and is not a location for the init program, so option A is a wrong answer. The /etc/lib/systemd/ directory is the location of the systemd program, and thus option D is also an incorrect choice.
2- Which of the following is true concerning systemd service units? (Choose all that apply.)
- Services can be started at system boot time.
- Services can be started in parallel.
- A service can be started based on a timer.
- A service can be started after all other services are started.
- A service can be prevented from starting at system boot time.
- Services can be started at system boot time.
- Services can be started in parallel.
- A service can be started based on a timer.
- A service can be started after all other services are started.
- A service can be prevented from starting at system boot time.
This is a tricky question, because all of these statements are true concerning systemd service units. It makes you realize that systemd‐managed systems are very flexible.
3- Which of the following is not a systemd target unit?
- runlevel7.target
- emergency.target
- graphical.target
- multi-user.target
- rescue.target
Explanation
There is no runlevel7.target. The legitimate systemd targets, which provide backward SysV init compatibility, go from runlevel0.target through runlevel6.target. Therefore, option A is the correct answer. The emergency.target is a special systemd target unit used to enter emergency mode. When your system goes into emergency mode, the system only mounts the root filesystem and mounts it as read‐only. Therefore, option B is a systemd target unit and not a correct answer. The graphical.target is a legitimate systemd target, which provides multiple users access to the system via local terminals and/or through the network and offers a GUI. Thus, option C is an incorrect choice. The multi-user.target is also a legitimate systemd target, just like the graphical.target, except that it does not offer a GUI. Therefore, option D is also a wrong answer. The rescue.target is like emergency.target, but it mounts the root filesystem for reading and writing. Therefore, option E is an incorrect choice.
runlevel7.target
There is no runlevel7.target. The legitimate systemd targets, which provide backward SysV init compatibility, go from runlevel0.target through runlevel6.target. Therefore, option A is the correct answer. The emergency.target is a special systemd target unit used to enter emergency mode. When your system goes into emergency mode, the system only mounts the root filesystem and mounts it as read‐only. Therefore, option B is a systemd target unit and not a correct answer. The graphical.target is a legitimate systemd target, which provides multiple users access to the system via local terminals and/or through the network and offers a GUI. Thus, option C is an incorrect choice. The multi-user.target is also a legitimate systemd target, just like the graphical.target, except that it does not offer a GUI. Therefore, option D is also a wrong answer. The rescue.target is like emergency.target, but it mounts the root filesystem for reading and writing. Therefore, option E is an incorrect choice.
Systemd targets
provide backward SysV init compatibility
include:
* runlevel0-6.target
* emergency.target
* graphical.target
* multi-user.target
* rescue.target
4- You need to modify a systemd service unit configuration. Where should the modified file be located?
- /etc/system/systemd/
- /usr/lib/system/systemd/
- /etc/systemd/system/
- /usr/lib/systemd/system/
- /run/system/systemd/
/etc/systemd/system/
Any modified systemd service unit configuration file should be stored in the /etc/systemd/system/ directory. This will prevent any package upgrades from overwriting it and keep the directory precedence from using the unmodified service unit copy, which may reside in the /usr/lib/systemd/system/ directory. The directories in options A and B are made up. The /usr/lib/systemd/system/ directory should only store unmodified unit files, which are provided by default, and thus option D is an incorrect answer. The /run/system/systemd/ directory is also made up.
5- On your server, you need Service‐B to start immediately before Service‐A. Within the systemd Service‐A unit configuration file, what directive should you check and potentially modify?
- Conflicts
- Wants
- Requires
- Before
- After
After
For starting Service‐B immediately before starting Service‐A, the Service‐A unit configuration file will need to employ the After directive, set to something like After=Service-B.unit. Therefore, option E is the correct answer. The Conflicts directive sets the unit to not start with the designated units. If any of the designated units start, this unit is not started. Therefore, option A is a wrong answer. The Wants directive sets the unit to start together with the designated units. If any of the designated units do not start, this unit is still started. Therefore, option B is also an incorrect answer. The Requires directive sets the unit to start together with the designated units. If any of the designated units do not start, this unit is not started. Thus, option C is a wrong choice. The Before directive sets this unit to start before the designated units. While this should be set in Service‐B’s unit configuration file, it does not apply, in this case, to Service‐A’s configuration file. Therefore, option D is also an incorrect answer.
6- For setting environment parameters within a unit configuration file, which directives should you potentially employ? (Choose all that apply.)
- Type
- Environment
- EnvironmentParam
- EnvironmentFile
- PATH
- Environment
- EnvironmentFile
Linux systems use environment variables to store information about the shell session and working environment. If you need to ensure that a particular environment variable is set properly for your service, you need to use the Environment directive and/or the EnvironmentFile directive for setting environment parameters. Therefore, options B and D are correct answers. The Type directive sets the unit startup type, which can be, for example, forking. Thus, option A is a wrong answer. The EnvironmentParam is a made‐up directive. PATH is an environment variable, which you may modify for your unit’s environmental parameters. However, it is not a directive.
7- You attempt to jump to a systemd target using the systemctl isolate command, but it will not work. You decide to look at the target unit file. What might you see there that is causing this problem?
- static
- AllowIsolate=yes
- Type=oneshot
- AllowIsolate=no
- disabled
AllowIsolate=no
If a target unit file has the AllowIsolate=no setting, the target cannot be used with the systemctl isolate command. Therefore, option D is the correct answer. Option A’s static is an enablement state displayed for a unit file via the systemctl –list-unit-files command. Thus, option A is a wrong answer. The AllowIsolate=yes directive permits the target to be used with the systemctl isolate command. Therefore, option B is also an incorrect choice. The Type=oneshot is a service unit directive, and you would not find it in a target unit file. Thus, option C is a wrong answer. Option E’s disabled is also an enablement state, like static, making option E a wrong choice as well.
8- You have modified an OpenSSH service’s configuration file, /etc/ssh/ssh_config. The service is already running. What is the best command to use with systemctl to make this modified file take immediate effect?
- reload
- daemon-reload
- restart
- mask
- unmask
reload
The best command to make the modified file take immediate effect for the OpenSSH service is systemctl reload. This command will load the service configuration file of the running designated service without stopping the service. Therefore, option A is the best answer. A daemon-reload will load the unit configuration file and not the service configuration file. The restart command will stop and immediately restart the service. While this will load the modified service configuration file, it will also disrupt the service for current service users. The mask command prevents a particular service from starting; the unmask command undoes the mask command’s effects.
9- Your system uses systemd and has a service currently set to not start at system boot. You want to change this behavior and have it start. What systemctl command should you employ for this service?
- restart
- start
- isolate
- disable
- enable
enable
To set a particular service unit to start at boot time, you need to use the systemctl enable command followed by the service unit name. Therefore, option E is the correct answer. The restart command will stop and immediately restart the service but does not control whether or not a service unit is started at system boot. The start command will start the service but does not control whether or not a service unit is started at system boot. The isolate command is used with systemd target units, not service units. Option D’s disable command will set a particular service unit to not start at boot time (disable it from starting).
11- Your systemd system is taking a long time to boot and you need to reduce the boot time. Which systemd-analyze command is the best to start narrowing down which units need to be investigated first?
- time
- dump
- failure
- blame
- verify
blame
The blame command displays the amount of time each running unit took to initialize, and the units and their times are listed starting from the slowest to the fastest. That way, you can start investigating the units at the list’s top. The time command displays the amount of time system initialization spent for the kernel, and the initial RAM filesystem, as well as the time it took for normal system user space to initialize. However, it does not help you determine which unit configurations may be to blame for the slow boot. The dump command displays data concerning all the units and the data is not in a format that lets you easily track down what unit takes the most time to initialize at boot. Therefore, option B is an incorrect choice. Option C’s failure is a service state, indicating that the service has failed. The verify command is handy in that it scans unit files and displays warning messages if any errors are found. However, it does not provide configuration information that can assist you in uncovering the reason a system is slow to boot.
12- Your older Debian‐based Linux distribution system uses SysV init. It will soon be upgraded to a Debian‐based distro that uses systemd. To start some analysis, you enter the runlevel command. Which of the following are results you may see? (Choose all that apply.)
- N 5
- 3 5
- N 2
- 2 3
- 1 2
- N 2
- 1 2
Debian‐based Linux distributions that use SysV init only use runlevels from 0 through 2. The runlevel command shows the previous runlevel, or N for newly booted. Therefore, the only options that this runlevel command would show on an older Debian‐based Linux distribution system, which uses SysV init, are C and E. Option A is incorrect, because it shows 5 as the current runlevel, and Debian‐based distros don’t use that runlevel. Option B is also incorrect, because it also shows 5 as the current runlevel. Option D is incorrect because it shows 3 as the current runlevel, and the Debian‐based distros do not use that runlevel either.
13- You’ve recently become the system administrator for an older Linux server, which still uses SysV init. You determine that its default runlevel is 3. What file did you find that information in?
- /etc/inittab
- /etc/rc.d
- /etc/init.d/rc
- /etc/rc.d/rc
- /etc/rc.local
/etc/inittab
For SysV init systems, the default runlevel is stored within the /etc/inittab file within the initdefault record. Therefore, option A is the correct answer. The /etc/rc.d is a directory and not a file. Thus, option B is a wrong answer. The rc file is a script that can reside in either the /etc/init.d/ or the /etc/rc.d/ directory. It runs the scripts that start the various system services when jumping runlevels or booting the system. However, this script does not contain any information concerning the default runlevel. Therefore, options C and D are incorrect choices. The /etc/rc.local file allows you to issue certain commands or run any scripts as soon as system initialization is completed. However, this script also does not contain any information concerning the default runlevel.
14- Which directory on an old SysV init system stores the service startup scripts?
- /usr/lib/systemd/system/
- /etc/rc.d/rcn.d/
- /etc/init.d/
- /etc/systemd/system/
- /run/systemd/system/
/etc/init.d/
The directory that stores the service startup scripts for an old (and a new) SysV init system is the /etc/init.d/ directory. Therefore, option C is the correct answer. The /etc/rc.d/rcn.d/ directories are used on a SysV init system, but they contain symbolic links to the scripts within the /etc/init.d/ directory. Thus, option B is an incorrect answer. Options A, D, and E are all systemd directories. Therefore, they are incorrect choices.
15- You are managing a SysV init system and need to perform some emergency maintenance at runlevel 1. To do this, you need to jump runlevels. What command could you employ? (Choose all that apply.)
- telinit S
- telinit 1
- init one
- init s
- init 1
- telinit S
- telinit 1
- init s
- init 1
Runlevel 1 is also called single‐user mode. You can employ either the init or the telinit command to jump to that runlevel and pass them one of the three following arguments: 1, s, or S. Therefore, options A, B, D, and E are correct answers. You cannot use the one argument to reach runlevel 1, and therefore option C is the only wrong choice.
16- A customer has complained that a service on your SysV init system is not working. Which of the following commands is the best command to use to check the service?
- service start
- service status
- service –status-all
- service stop
- service reload
service status
The best command to use is the service status command, passing the service name to it as an argument. This will display the service’s current status and allow you to start the troubleshooting process quickly. Therefore, option B is the correct answer. The service start command will start the designated service, but you do not know whether or not this service was stopped. Thus it is not the best command to use, and option A is an incorrect choice. The service –status-all command is not the best command to use because it shows the status of all the various services. Thus, option C is a wrong answer. The service stop command will stop the designated service and provide a FAILED status if it was already stopped. However, this is not the best way to check a service’s status on a SysV init system. The service reload command will load the designated service’s configuration file and provide a FAILED status if the service is stopped. Yet again, this is not the proper way to check a service’s status.
Systemd
- A modern system and service manager for Linux that replaces traditional SysV init
- Handles system initialization, service management, process supervision, and various system functions like logging (journald), networking, and time synchronization in a unified framework.
SysV Init
- The traditional Unix System V initialization system used in older Linux distributions
- Manages system startup through sequential execution of shell scripts organized by runlevels (0-6), where each runlevel represents a different system state (single-user, multi-user, GUI, shutdown, etc.).
17- You need to enable the DHCP service on your Red Hat–based SysV init system for runlevels 3 and 5. Which of the following commands should you use?
- service enable dhcp 3,5
- chkconfig –levels 3,5 dhcp on
- chkconfig –levels 35 on dhcp
- chkconfig –levels 35 dhcp on
- service enable dhcp 35
chkconfig –levels 35 dhcp on
To enable the DHCP service on your Red Hat–based SysV init system for runlevels 3 and 5, the correct command to use is the chkconfig –levels 35 dhcp on command. Therefore, option D is the correct answer. Options A and E are incorrect, because you cannot use the service command to enable SysV init services. Option B is a wrong answer because you cannot use a delimiter, such as a comma, to separate the runlevel list. Option C is an incorrect choice because this command has its service name and the on argument flip‐flopped.
18- You need to enable the DHCP service on your Debian‐based SysV init system for the default runlevels. Which of the following commands should you use?
- update-rc.d dhcp default
- chkconfig –default dhcp on
- update-rc.d default dhcp
- update-rc.d defaults dhcp
- update-rc.d dhcp defaults
update-rc.d dhcp defaults
To enable the DHCP service on your Debian‐based SysV init system for default runlevels, the correct command to use is update-rc.d dhcp defaults. Therefore, option E is the correct answer. Option A is incorrect because the last command argument should be defaults and not default. Option B is a wrong answer because you cannot use the chckconfig command on a Debian‐based distribution. Option C is an incorrect choice because this command has the service name and the default argument flip‐flopped. Also, it is using the wrong argument—the argument should be defaults. The command used in option D is incorrect because this command has the service name and the defaults argument flip‐flopped.
19- Which of the following would be the appropriate base name for a mount unit file that mounts a filesystem at the /var/log/ mount point?
- /var/log.mount
- /var/log.unit
- var-log.mount
- var-log.unit
- var/log.mount
var-log.mount
The mount unit filenames are created by having the absolute directory reference’s preceding forward slash (/) removed, subsequent forward slashes are converted to dashes (–), and trailing forward slashes are removed. Mount unit filenames also have a .mount extension. Therefore, the mount unit file for the /var/log/ mount point would be var-log.mount. Thus, option C is the correct answer. The /var/log.mount unit filename is incorrect because the forward slashes were not removed or replaced. The /var/log.unit base name is incorrect because the forward slashes were not removed or replaced. Also, the wrong file extension is used. The var-log.unit base name is incorrect because the wrong file extension is used. The var/log.mount unit filename is incorrect because the middle forward slash was not replaced by a dash.
mount unitnfile
- A systemd unit file (.mount) that defines how and where filesystems should be mounted
- Automatically generated from /etc/fstab entries or manually created to specify mount points, filesystem types, options, and dependencies (e.g., home.mount for mounting /home).
- The mount unit filenames are created by having the absolute directory reference’s preceding forward slash (/) removed, subsequent forward slashes are converted to dashes (–), and trailing forward slashes are removed.
- e.g.: /var/log/ -> var-log.mount
20- You are managing a systemd system and need to create an automount unit file. Which of the following directives should you review to possibly include in this file’s [Automount] section? (Choose all that apply.)
Where
Options
DirectoryMode
TimeOutIdleSec
What
- Where
- DirectoryMode
- TimeOutIdleSec
For systemd automount unit files, the only directives that can be included in the [Automount] file section are Where, DirectoryMode, and TimeOutIdleSec. Thus, options A, C, and D are correct answers. The Options and What directives are ones you would see in a mount unit file’s [Mount] section. Therefore, options B and E are incorrect choices.