Disabling the unit
You can also achieve a similar effect by disabling the unit. Disabling a unit removes the symbolic links to the unit files, preventing it from being started.
sudo systemctl disable <unit_name>
Explanation:
- The ‘systemctl disable‘ command removes symbolic links related to the specified unit, preventing it from being started.
- This is an alternative method to achieve a similar effect to masking.
For example:
sudo systemctl disable nginx.service
Output:
Output shows disabled that the unit has been disabled successfully.
To re-enable the unit :
sudo systemctl enable <unit_name>
Above command re-enables the unit and for more clarity refer to the below example:
sudo systemctl enable nginx.service
Output shows that the unit has been re-enabled.
How to mask a systemd unit in Linux?
Systemd is a system and service manager for Linux operating systems, providing a range of functionalities for managing system processes. In some cases, you may want to hide or disable a systemd unit to prevent it from starting automatically. This process is known as “masking” a systemd unit. In this article, we’ll explore the steps to mask a systemd unit in Linux.