CompTIA Linux+ (XK0-006)Services and User ManagementMedium
A system administrator is configuring a new Linux server and needs to enable a `systemd` timer unit named `mybackup.timer` to ensure that a corresponding service `mybackup.service` runs periodically. After creating both unit files, which command should the administrator use to make sure the timer starts automatically at boot and becomes active immediately?
- Asystemctl start --now mybackup.timer
- Bsystemctl enable mybackup.service && systemctl start mybackup.timer
- Csystemctl enable --now mybackup.timer
- Dsystemctl start mybackup.timer && systemctl enable mybackup.timer
Show answer & explanationAnswer & explanation
Correct answer: C. systemctl enable --now mybackup.timer
The `systemctl enable` command creates symlinks to allow a unit to start at boot. The `--now` flag, when used with `enable`, not only enables the unit for future boots but also starts it immediately. This single command fulfills both requirements: starting at boot and becoming active immediately.
Why the other options are wrong
- A. `systemctl start --now` is not a valid combination; `--now` is an option for `enable` to also `start` the unit.
- B. Enabling `mybackup.service` directly is not necessary for the timer to function; the timer unit itself should be enabled and started. The timer unit's `[Timer]` section points to the service.
- D. This sequence works, but `systemctl enable --now` is a more concise and idiomatic way to achieve the same result.
systemctl enable --now
A `systemctl` command combination that both enables a `systemd` unit to start automatically at boot and starts it immediately in the current session.
- Combines `enable` and `start` actions.
- Useful for quickly activating services/timers permanently.
- Avoids separate commands for immediate activation and boot persistence.
Memory trick: ENABLE NOW for instant boot-up power!