Managing System Services in Linux systemctl Command (original) (raw)

Last Updated : 18 May, 2026

Systemd is a modern system and service manager for Linux that serves as the core initialization process (PID 1). It controls system startup, manages background services, and ensures efficient system operation.

Example: Starting and Stopping a System Service in Linux****:**

**Syntax:

systemctl start [service_name]
systemctl stop [service_name]
systemctl status [service_name]

**Example with Apache Web Server

**Commands:

systemctl start apache2
systemctl status apache2

**Output:

image---2025-11-11T170032819

Output

**Command:

systemctl stop apache2
systemctl status apache2

**Output:

Syntax of `systemctl` command in Unix

systemctl [command] [service]

Options available in `systemctl` command in Unix

Option Description Example
--type Filter output by unit type (service, socket, timer) systemctl --type=service
--all Lists all units including inactive ones systemctl --all
--failed Lists all units that have failed systemctl --failed
--state Filter output by unit state (active, inactive, failed) systemctl list-units --state=failed
--user Manage user services instead of system services systemctl --user
-q, --quiet Suppress output messages systemctl daemon-reload --quiet

Managing System Services in Linux

1. Enabling and Disabling Services

Enabling a Service

**Syntax:

systemctl enable [service]

**Example:

sudo systemctl enable apache2

**Output:

image---2025-11-11T170049164

Output

**Disabling a Service

**Syntax:

systemctl disable [service]

**Example:

sudo systemctl disable apache2

**Output:

image---2025-11-11T170049690

2. Viewing the Status of a Service

**Syntax:

systemctl status [service]

**Example:

sudo systemctl status apache2

**Output:

file

3. Restarting and Reloading Services

Restarting a Service

**Syntax:

systemctl restart [service]

**Example:

sudo systemctl restart apache2

**Output:

file

Output

Reloading a Service

**Syntax:

systemctl reload [service]

**Example:

sudo systemctl reload apache2

**Output:

file

Output

4. Masking and Unmasking Services

Masking a Service

**Syntax:

systemctl mask [service]

**Example:

sudo systemctl mask apache2

**Output:

image---2025-11-11T170055074

Unmasking a Service

**Syntax:

systemctl unmask [service]

**Example:

sudo systemctl unmask apache2

**Output:

image---2025-11-11T170056370

5. Changing the Default Target

**Syntax:

systemctl set-default [target]

**Example:

sudo systemctl set-default graphical.target

**Output:

image---2025-11-11T170057498

Output

6. Listing Unit Files

**Syntax:

systemctl list-unit-files

**Output:

image---2025-11-11T170058091

Output

Also Check: