Prevent maintenance.service from being started by dependencies or manually.
Use a stronger control than merely disabling boot activation.
Which command is appropriate?
systemctl mask links a unit to /dev/null and rejects normal start requests. unmask removes the mask.
Detailed explanation
systemctl disable maintenance.serviceIncorrect. disable does not prevent a manual start.
Incorrect. disable does not prevent a manual start.
systemctl mask maintenance.serviceCorrect. mask blocks ordinary start requests.
Correct. mask blocks ordinary start requests.
systemctl status maintenance.serviceIncorrect. status only displays state.
Incorrect. status only displays state.
systemctl preset maintenance.serviceIncorrect. preset applies distribution policy and is not a hard mask.
Incorrect. preset applies distribution policy and is not a hard mask.
Try it yourself
An example you can run in a temporary verification environment.
systemctl --help 2>&1 | grep -E -- 'mask|unmask' | head -n 2Expected result
maskとunmaskに関するhelp行Key points
- mask blocks starts
- disable only affects auto-start
- unmask reverses it
Notes
- Environment: systemd systemctl help / unit変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.