CompTIA Linux+ (XK0-006)Services and User ManagementEasy

A junior administrator is configuring a new Linux server and needs to enable a `systemd` service named `webserver.service` so that it starts automatically at boot time. Which command should be used?

  1. Achkconfig webserver on
  2. Bsystemctl enable webserver.service
  3. Csystemctl autostart webserver.service
  4. Dsystemctl start webserver.service
Show answer & explanation

Correct answer: B. systemctl enable webserver.service

The `systemctl enable` command creates the necessary symlinks to ensure that a `systemd` unit starts automatically when the system boots.

Why the other options are wrong

  • A. `chkconfig` is an older command-line tool used with SysVinit init systems, not `systemd`.
  • C. There is no `systemctl autostart` command.
  • D. `systemctl start` only starts the service for the current session; it does not configure it to start at boot.

systemctl enable

The `systemctl enable` command configures a `systemd` unit to start automatically at system boot by creating appropriate symlinks.

  • Creates symlinks in `/etc/systemd/system/*.wants/` or `/etc/systemd/system/*.requires/`.
  • Does not start the service immediately.
  • Requires `root` privileges.

Memory trick: Enable for Boot: Make It Start Automatically!

More Services and User Management questions