systemctl commands cheat sheet
Service status
-
systemctl status nginxShows the state of the service: whether it's running, since when, the main process ID, memory usage, and the last 10 lines of its log. Without a service name, it shows the state of the whole system.
Example:
Active: active (running) since Sun 2026-11-29 09:12:44 IST; 2h ago -
systemctl status nginx -n 50 --no-pagerShows 50 log lines instead of 10, straight in the terminal without a pager. The value 0 hides the log.
-
systemctl status nginx -lShows lines in full, without shortening long lines with an ellipsis.
-
systemctl is-active nginxReturns the state of the service in one word, such as active, inactive, or failed. The exit code is 0 when the service is running, so the command suits scripts.
Example:
active -
systemctl is-enabled nginxChecks whether the service is set to start automatically. The common answers are enabled, disabled, static (a unit with no autostart setting, started by other units), and masked.
Example:
enabled -
systemctl is-failed nginxChecks whether the service is in the failed state. The exit code is 0 when the service has failed.
-
systemctl show nginx -p ActiveState -p SubStateShows specific properties of the service in name=value format. Each property appears on its own line, and without -p all properties are shown.
Example:
First line: ActiveState=active | Second line: SubState=running -
systemctl show nginx -P MainPIDShows only the value, without the property name. Handy in scripts, for example to get the main process ID of the service.
Example:
1234 -
systemctl list-dependencies nginxShows the units the service depends on, as a tree.
Starting, stopping, and reloading
-
sudo systemctl start nginxStarts the service. It doesn't set the service to start automatically at boot.
-
sudo systemctl stop nginxStops the service. If the service is set to start automatically, it starts again the next time the server boots.
-
sudo systemctl restart nginxStops and starts the service again, and starts it even if it wasn't running. Open connections to the service are dropped. You can list several services in one command.
-
sudo systemctl reload nginxAsks the service to reload its configuration files without stopping. Not every service supports reloading. The command doesn't reload the unit file itself; use daemon-reload for that.
-
sudo systemctl reload-or-restart nginxReloads the configuration when the service supports it, and otherwise restarts the service.
-
sudo systemctl try-restart nginxRestarts the service only if it's running right now. A stopped service stays stopped.
-
sudo systemctl kill nginxCaution: sends a signal (SIGTERM by default) to the processes of the service. Use it only when a normal stop hangs.
-
sudo systemctl kill -s SIGKILL nginxCaution: forcibly ends all the processes of the service, with no chance to save data or close connections cleanly.
Starting automatically at boot
-
sudo systemctl enable nginxSets the service to start automatically every time the server boots. It doesn't start the service now.
-
sudo systemctl enable --now nginxSets the service to start automatically and starts it right away, in one command. The usual form after installing a new service.
-
sudo systemctl disable nginxTurns off automatic start. The service keeps running until you stop it or until the server boots again.
-
sudo systemctl disable --now nginxTurns off automatic start and stops the service right away.
-
sudo systemctl reenable nginxTurns automatic start off and on again, for example after a change in the [Install] section of the unit file.
-
sudo systemctl mask nginxCaution: blocks the service completely. The unit file is linked to /dev/null, and the service can't be started, not even manually or as a dependency of another service, until you unmask it. Suits a service that must not run, for example when two services conflict.
-
sudo systemctl mask --now nginxCaution: blocks the service and stops it right away.
-
sudo systemctl unmask nginxUnmasks the service. The service doesn't start on its own, so run start afterward, and enable if needed.
Listing services and units
-
systemctl list-units --type=service --state=runningLists all the services running right now.
-
systemctl list-units --type=service --allLists all the services loaded in memory, including inactive ones.
-
systemctl --failedLists all the units that failed. The first check after the server reboots or when something isn't working. Same as the --state=failed option.
-
systemctl list-unit-files --type=serviceLists all the installed service files and the autostart state of each, including services that aren't loaded right now.
-
systemctl list-unit-files --type=service --state=enabledLists only the services set to start automatically at boot.
-
systemctl list-units --type=service | grep -i phpFinds a service by part of its name, when you're not sure of its exact name on your distribution.
Editing units and settings
-
systemctl cat nginxShows the unit file of the service and every drop-in file that applies to it, with the path of each file. This way you see all the settings of the service in one place.
Example:
# /usr/lib/systemd/system/nginx.service -
sudo systemctl edit nginxOpens a drop-in file named override.conf in an editor, in the /etc/systemd/system/nginx.service.d/ directory. Settings in this file override the original file, and they're kept after a package update. Once you save, the settings are reloaded automatically. For example, the line Restart=on-failure under the [Service] header restarts the service automatically when it fails.
-
sudo systemctl edit --full nginxOpens a full copy of the unit file in /etc/systemd/system for editing, which replaces the file from the package. Package updates to the original file won't apply to it, so a drop-in file is usually the better choice.
-
sudo SYSTEMD_EDITOR=nano systemctl edit nginxOpens the file in a specific editor. Without this variable, the command uses the editor set in the EDITOR or VISUAL environment variable, and if neither is set, it tries editor, nano, vim, and vi in that order.
-
ExecStart=In a drop-in file: an empty ExecStart= line resets the command set in the original file, and the new ExecStart= line follows it. A regular service allows only one ExecStart command, so without the reset you get an error.
Example:
First line: ExecStart= | Second line: ExecStart=/usr/local/bin/myapp --port 8080 -
sudo systemctl daemon-reloadReloads all the unit files. Run it after creating or manually editing a unit file or a drop-in file (not after systemctl edit, which does it on its own), and then restart the service so the settings apply to it.
-
sudo systemctl revert nginxCaution: returns the service to the package settings. It deletes the drop-in files and the copy in /etc/systemd/system, and unmasks it.
-
sudo systemctl reset-failed nginxClears the failed state of the service, for example after the problem was fixed. Without a service name, it clears all the units.
Scheduled tasks (timers)
-
systemctl list-timersLists the active scheduled tasks in order of their next run: when each task runs next (NEXT), how much time is left (LEFT), when it last ran (LAST), and which service it starts (ACTIVATES).
-
systemctl list-timers --allAlso lists scheduled tasks that aren't active.
-
sudo systemctl enable --now backup.timerStarts a scheduled task and sets it to start every time the server boots. You start the .timer file, and at the set time it runs the service with the same name.
-
systemctl status backup.timerShows the state of the scheduled task and the time of its next run. The output of the runs themselves is in the log of the service, for example journalctl -u backup.service.
-
sudo systemctl start backup.serviceRuns the service behind the scheduled task right away, without waiting for the next run. Useful for testing.
Service logs with journalctl
-
journalctl -u nginxShows the whole log of the service, starting from the oldest entry. You can give -u several times to see several services together.
-
journalctl -u nginx -fShows the last lines and keeps showing new lines as they're written. Exit with Ctrl+C.
-
journalctl -u nginx -n 100 --no-pagerShows the last 100 lines straight in the terminal, without a pager.
-
journalctl -u nginx -eOpens the log in the pager and jumps to its end, to the newest entries.
-
journalctl -u nginx -rShows the log in reverse order, newest first.
-
journalctl -u nginx --since "1 hour ago"Shows only entries from the last hour. Values such as today, yesterday, "2 days ago", or -30min also work.
-
journalctl -u nginx --since "2026-11-29 08:00" --until "2026-11-29 09:00"Shows entries in a specific time range. The date is in year-month-day format, and you can leave out the seconds.
-
journalctl -u nginx -bShows only entries from the current boot of the server.
-
journalctl -b -1 -p errShows errors from the previous boot of the server, for example to investigate an unexpected reboot. Available only when logs are kept on disk between boots.
-
journalctl --list-bootsLists the server boots saved in the journal, with a number for each boot (0 is the current one, -1 the previous one) and the times of the first and last entries.
-
journalctl -p err -bShows all the errors from all services since the current boot. The err level also includes the more severe levels (crit, alert, emerg).
-
journalctl -p warning..err -u nginxShows entries within a range of levels, here from warnings to errors.
-
journalctl -u nginx -g "timeout"Filters entries by a regular expression in the message text. When the expression is all lowercase, the search is case-insensitive.
-
journalctl -k -bShows only kernel messages from the current boot, much like dmesg. Useful for disk, memory, and network problems.
-
journalctl -xeu nginxShows the end of the log of the service, with extra explanations for some messages. The combination often suggested in the error message when a service fails to start.
-
journalctl -u nginx -o short-isoShows the time of entries in full ISO 8601 format, including the year and time zone. The cat format shows only the messages, and the json format suits processing by a program.
Log disk usage
-
journalctl --disk-usageShows how much disk space all the journal files take up.
Example:
Archived and active journals take up 1.2G in the file system. -
sudo journalctl --vacuum-size=500MCaution: deletes old archived journal files until their total size drops below 500 MB. Deleted entries can't be recovered. You can use K, M, G, or T.
-
sudo journalctl --vacuum-time=2weeksCaution: deletes archived journal files older than two weeks. Possible time units: s, m, h, days, weeks, months, and years.
-
sudo journalctl --rotate --vacuum-size=500MCaution: cleanup applies only to archived files, not to the active file. --rotate first closes the active files and moves them to the archive, and only then the deletion runs.
Rebooting and system states
-
sudo systemctl rebootCaution: reboots the server. All services stop, and SSH connections drop until the server is back up.
-
sudo systemctl poweroffCaution: shuts the server down. On a remote server, you can't power it back on over SSH.
-
sudo systemctl soft-rebootCaution: restarts all the services and programs on the system without restarting the kernel, so it's faster than reboot. Available only on distributions with a recent version of systemd.
-
systemctl get-defaultShows the boot target the server starts into by default. On servers this is usually multi-user.target, a text interface without a graphical desktop.
Example:
multi-user.target -
sudo systemctl set-default multi-user.targetSets the boot target that applies from the next boot of the server. graphical.target includes a graphical desktop.
-
sudo systemctl isolate rescue.targetCaution: switches right away to maintenance mode and stops every service that isn't part of it, including network services and SSH. Run it only from a direct console on the server, not over an SSH connection.
User services (--user)
-
systemctl --user status myappManages the services of the logged-in user, without sudo. Most systemctl commands on this page also work with --user, against the user's service manager.
-
systemctl --user enable --now myappStarts a user service and sets it to start automatically when the user's service manager starts, usually when the user logs in. The user's unit files are kept in the ~/.config/systemd/user directory.
-
systemctl --user daemon-reloadReloads the user's unit files, after creating or manually editing them.
-
journalctl --user-unit myappShows the log of a user service.
No matching commands.
Where unit files are kept
- /usr/lib/systemd/system: The unit files installed with packages. Don't edit them, because a package update overwrites the changes.
- /etc/systemd/system: The system administrator's unit files, and also where the drop-in files created with systemctl edit are saved. A file in this directory overrides a file with the same name in /usr/lib/systemd/system.
- Drop-in directories: .conf files in a directory named after the service with a .d suffix, for example /etc/systemd/system/nginx.service.d/, are added to the unit file in alphabetical order and change only the settings they contain.
- User services: The unit files of a regular user are in ~/.config/systemd/user and are managed with systemctl --user.
restart, reload, and daemon-reload
- reload: The service reloads its configuration files, such as the site files of the web server, without stopping and without dropping connections.
- restart: The service stops and starts again. Needed when the service doesn't support reloading or when you change settings that are read only at startup.
- daemon-reload: systemd itself rereads the unit files. Needed after a change to a unit file, followed by a restart of the service.
The service name nginx on this page is an example, so replace it with the real service name. The same service may have different names on different distributions, so when you're not sure of the name, look it up with systemctl list-unit-files. General commands for working on a server are on the Linux commands page.
On a Linux VPS, you connect over SSH with full root access and manage the services on the server with every command on this page: starting and stopping, automatic start, editing settings, scheduled tasks, and reading logs.
systemctl commands FAQ
What is the difference between restart and reload in systemctl?
reload asks the service to reload its configuration files without stopping, so open connections aren't dropped. restart stops the service and starts it again, so it fits when the service doesn't support reloading or when the change is read only at startup. When you're not sure, systemctl reload-or-restart picks the right way on its own.
How do I set a service to start automatically with the server?
Run sudo systemctl enable --now with the service name. The command sets the service to start every time the server boots and starts it right away. To make sure the setting took effect, run systemctl is-enabled with the service name, and the answer should be enabled.
How do I find out why a service won't start?
Start with systemctl status and the service name, which shows the state and the last lines from the log. For more details, run journalctl -xeu and the service name, which shows the end of the log with explanations. When the problem is in the service's configuration file, most services offer their own check command, for example nginx -t, and after the fix you restart the service.
How do I change a service setting without editing the original file?
Run sudo systemctl edit and the service name. A drop-in file opens, where you write only the settings you want to change, for example Restart=on-failure under [Service]. The changes are saved separately from the package file, so a package update doesn't delete them. After saving, restart the service, and systemctl cat shows all the settings that apply to it.
How do I free up disk space taken by logs?
journalctl --disk-usage shows how much space the logs take up. To free up space, run, for example, sudo journalctl --rotate --vacuum-time=2weeks, which deletes logs older than two weeks, or --vacuum-size with a maximum size. We recommend keeping recent logs, because they help track down problems.