Explore key concepts of systemd and service management in Linux, including command usage, service states, and unit files. This quiz covers fundamental techniques and tools essential for managing services effectively within the Linux ecosystem.
Which systemctl command should be used to start the sshd service immediately on a running Linux system?
Explanation: The 'systemctl start sshd' command immediately starts the sshd service on a running system. The 'enable' subcommand configures the service to start automatically at boot, not to start it right away. The 'activate' and 'initiate' options are not valid systemctl commands for starting services. Only the 'start' option performs the desired action in this scenario.
What systemctl command will prevent the httpd service from being automatically started during system boot, while allowing manual starts?
Explanation: The 'systemctl disable httpd' command prevents the service from launching at boot but does not affect manual starting. 'Stop' merely halts the service temporarily without changing future startup behavior. 'Remove' is not a valid systemctl command, and 'block' does not exist in systemctl for this purpose. Disabling is the proper action for this administrative need.
In systemd, service behavior and configuration details are primarily defined in which type of unit file?
Explanation: The '.service' unit file defines how a specific service is started, stopped, and managed by systemd. '.target' files group units together and help organize boot order, but they don't provide service-specific configuration. '.mount' files handle filesystem mounting, and '.slice' files are used for resource management and delegation. Only the '.service' file directly configures services.
What is the correct systemctl command to display detailed status information about the cron service, including recent logs?
Explanation: The 'systemctl status cron' command shows detailed information about the service's current status and recent logs. 'Info', 'list', and 'check' are not valid commands for viewing this level of detail for a service's state within systemctl. Only 'status' retrieves the necessary runtime and log information for the specified service.
If a service should only start after the network is fully up, which unit file directive ensures systemd waits for the network before starting the service?
Explanation: The 'After=network.target' directive in a unit file ensures that the service will only start after the network system is considered ready. 'StartsWith' and 'First' are not recognized unit directives, and 'DelayFor' does not exist for this purpose. Only 'After=network.target' establishes a reliable dependency on network availability in systemd.