What does systemctl mask do

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: The `systemctl mask` command prevents a systemd service from being started automatically, manually, or by any other service. It does this by creating a symbolic link from the service's unit file to `/dev/null`, effectively making the service unavailable.

Key Facts

What is systemctl?

Systemd is a modern system and service manager for Linux operating systems. It is responsible for booting up the system and managing its services. The `systemctl` command is the primary tool used to interact with systemd, allowing users and administrators to control services, manage system states, and query system information.

What does `systemctl mask` do?

The `systemctl mask` command is a powerful utility within the systemd ecosystem that serves to completely disable a service. When you mask a service, you are essentially telling systemd that this service should never be started under any circumstances. This is a more robust form of disabling a service compared to simply stopping it or disabling its automatic startup.

Technically, `systemctl mask ` works by creating a symbolic link from the service's unit file (e.g., `/etc/systemd/system/.service`) to the special device file `/dev/null`. The `/dev/null` device is a null device that discards all data written to it and provides an end-of-file indication when read. By linking the service's unit file to `/dev/null`, systemd treats the service as if it doesn't exist or is empty, thus preventing it from being started.

Why use `systemctl mask`?

There are several scenarios where masking a service is beneficial:

How to use `systemctl mask`

To mask a service, open a terminal and use the following command, replacing `` with the actual name of the service you wish to mask:

sudo systemctl mask 

For example, to mask the Apache web server service (often named `apache2` or `httpd`), you would run:

sudo systemctl mask apache2

You can mask multiple services at once by listing them:

sudo systemctl mask service1.service service2.service

How to check if a service is masked

You can verify if a service is masked by using the `systemctl status` command:

systemctl status 

If the service is masked, the output will typically include a line indicating it is masked, often showing the link to `/dev/null`.

Alternatively, you can check the existence of the symbolic link directly:

ls -l /etc/systemd/system/.service

If it's masked, you'll see output similar to:

lrwxrwxrwx 1 root root ... /etc/systemd/system/.service -> /dev/null

How to unmask a service

If you need to enable a masked service again, you can use the `systemctl unmask` command:

sudo systemctl unmask 

This command removes the symbolic link created by `systemctl mask`, allowing the service to be started again. After unmasking, you might need to explicitly start the service or enable it to start on boot using `systemctl start ` or `systemctl enable `, respectively.

Difference between `mask`, `disable`, and `stop`

It's important to understand the distinctions between these commands:

In summary, `systemctl mask` provides a definitive way to ensure a service remains inactive, making it a crucial tool for system administration, security, and stability management on Linux systems running systemd.

Sources

  1. systemctl - control the systemd system and service managerGPL-2.0-or-later
  2. Systemd - ArchWikiCC-BY-SA-3.0
  3. Systemctl Essentials: Managing Services on Linuxfair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.