The “systemctl mask
” and “systemctl disable
” are both crucial commands for Linux administrators, and you must know their differences to decide which one to choose in certain situations.
The “systemctl enable
” command allows your services to start on system boot. If you disable your service and other services or dependencies are using it, they are allowed to start your service on system boot.
However, if you mask your services using the “systemctl mask
” command, no matter what services or dependencies require your service, it will not start manually or on the system boot.
This is all done with the help of symbolic links, also known as symlinks.
For example:
The service is enabled because there is a symbolic link at the “/etc/systemd/system
” path to the unit file located at the “/lib/systemd/system
” path.
When you enable a service, the full path of the created symbolic link and target will be printed to stdout.
However, when you disable the service using the “systemctl disable
” command, it will remove the symbolic link, which surely is not going to affect your original unit file, but the service will not be able to load on the next boot when systemd reads the “/etc/systemd/system
” path.
Although the other services or dependencies can start the disabled service on the system boot, you can manually start it by firing up the command on the terminal.
But in the “systemctl mask
” command, the service is a symlink to the “/dev/null” file. which makes it impossible to start on system boot or manually by you, even if it is required by another service or dependency.
To let it start on system boot or manually by you or dependencies, you need to unmask it using the “systemctl unmask
” command, which will delete the symlink pointing to the “/dev/null
” file.
It is also important to know that you cannot mask critical services, like system services.
I hope you understood their difference in this TL;DR version. If you have any questions or quaries, please leave them in the comments section.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.