Basic systemctl commands

Basic systemctl commands
Photo by Lukas / Unsplash

Systemctl is a command line utility that is used to manage systemd services on Linux systems, and if you don't regularly manage Linux systems, you might find yourself guessing at the syntax before having to look it up.

So if you arrived here because that's you, here are the basics:

šŸ’”
Most examples will show servicename.service but the .service part is optional (systemctl will just search through.
ā—
All of the commands below assume that the current user has permissions to run them. In practice, you might need to prefix them with sudo.

Check the status of a service

systemctl status servicename
Screenshot showing the output of the linux command `systemctl status cron`

The output will show the path of the loaded service, whether the service is active (running), where to see the documentation for the service (in the above example the command man cron would load the manual for cron). It will also show the most recent log entries for the service.

Start a service

systemctl start servicename

Stop a service

systemctl stop servicename

Check for failed services

This will list all services that are in a failed state (i.e. they've crashed or errored and stopped). The simple command here is:

systemctl --failed

But this is equivalent to:

systemctl list-units --state=failed

Enable a service

Enabling a service means it will start automatically when the system next starts

systemctl enable servicename

Where as:

systemctl enable --now servicename

The above will enable the service for automatic start on next reboot but it will also immediately start the service too.

Disabling a service

This is the opposite of aboveā€“disabling a service will prevent it starting after the next reboot, disable --now will do the same but also immediately stop the service.

systemctl disable servicename
systemctl disable --now servicename

What else?

These are some basic commands, but if there's anything you regularly forget, please leave a comment so I can add it here!



Great! Next, complete checkout for full access to techbits.io
Welcome back! You've successfully signed in
You've successfully subscribed to techbits.io
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated