systemctl commands cheat sheet

This cheat sheet brings together systemctl and journalctl commands for managing services on Linux distributions that run systemd: starting and stopping services, starting them automatically at boot, editing units, scheduled tasks (timers), and reading logs. You can search for a command, filter by topic, and copy it with one click.

Service status

  • systemctl status nginx

    Shows 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-pager

    Shows 50 log lines instead of 10, straight in the terminal without a pager. The value 0 hides the log.

  • systemctl status nginx -l

    Shows lines in full, without shortening long lines with an ellipsis.

  • systemctl is-active nginx

    Returns 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 nginx

    Checks 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 nginx

    Checks whether the service is in the failed state. The exit code is 0 when the service has failed.

  • systemctl show nginx -p ActiveState -p SubState

    Shows 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 MainPID

    Shows 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 nginx

    Shows the units the service depends on, as a tree.

Starting, stopping, and reloading

  • sudo systemctl start nginx

    Starts the service. It doesn't set the service to start automatically at boot.

  • sudo systemctl stop nginx

    Stops the service. If the service is set to start automatically, it starts again the next time the server boots.

  • sudo systemctl restart nginx

    Stops 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 nginx

    Asks 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 nginx

    Reloads the configuration when the service supports it, and otherwise restarts the service.

  • sudo systemctl try-restart nginx

    Restarts the service only if it's running right now. A stopped service stays stopped.

  • sudo systemctl kill nginx

    Caution: 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 nginx

    Caution: 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 nginx

    Sets the service to start automatically every time the server boots. It doesn't start the service now.

  • sudo systemctl enable --now nginx

    Sets the service to start automatically and starts it right away, in one command. The usual form after installing a new service.

  • sudo systemctl disable nginx

    Turns off automatic start. The service keeps running until you stop it or until the server boots again.

  • sudo systemctl disable --now nginx

    Turns off automatic start and stops the service right away.

  • sudo systemctl reenable nginx

    Turns automatic start off and on again, for example after a change in the [Install] section of the unit file.

  • sudo systemctl mask nginx

    Caution: 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 nginx

    Caution: blocks the service and stops it right away.

  • sudo systemctl unmask nginx

    Unmasks 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=running

    Lists all the services running right now.

  • systemctl list-units --type=service --all

    Lists all the services loaded in memory, including inactive ones.

  • systemctl --failed

    Lists 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=service

    Lists 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=enabled

    Lists only the services set to start automatically at boot.

  • systemctl list-units --type=service | grep -i php

    Finds 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 nginx

    Shows 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 nginx

    Opens 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 nginx

    Opens 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 nginx

    Opens 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-reload

    Reloads 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 nginx

    Caution: 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 nginx

    Clears 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-timers

    Lists 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 --all

    Also lists scheduled tasks that aren't active.

  • sudo systemctl enable --now backup.timer

    Starts 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.timer

    Shows 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.service

    Runs the service behind the scheduled task right away, without waiting for the next run. Useful for testing.

Service logs with journalctl

  • journalctl -u nginx

    Shows 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 -f

    Shows the last lines and keeps showing new lines as they're written. Exit with Ctrl+C.

  • journalctl -u nginx -n 100 --no-pager

    Shows the last 100 lines straight in the terminal, without a pager.

  • journalctl -u nginx -e

    Opens the log in the pager and jumps to its end, to the newest entries.

  • journalctl -u nginx -r

    Shows 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 -b

    Shows only entries from the current boot of the server.

  • journalctl -b -1 -p err

    Shows 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-boots

    Lists 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 -b

    Shows 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 nginx

    Shows 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 -b

    Shows only kernel messages from the current boot, much like dmesg. Useful for disk, memory, and network problems.

  • journalctl -xeu nginx

    Shows 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-iso

    Shows 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-usage

    Shows 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=500M

    Caution: 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=2weeks

    Caution: deletes archived journal files older than two weeks. Possible time units: s, m, h, days, weeks, months, and years.

  • sudo journalctl --rotate --vacuum-size=500M

    Caution: 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 reboot

    Caution: reboots the server. All services stop, and SSH connections drop until the server is back up.

  • sudo systemctl poweroff

    Caution: shuts the server down. On a remote server, you can't power it back on over SSH.

  • sudo systemctl soft-reboot

    Caution: 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-default

    Shows 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.target

    Sets the boot target that applies from the next boot of the server. graphical.target includes a graphical desktop.

  • sudo systemctl isolate rescue.target

    Caution: 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 myapp

    Manages 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 myapp

    Starts 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-reload

    Reloads the user's unit files, after creating or manually editing them.

  • journalctl --user-unit myapp

    Shows the log of a user service.

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.

Did you know?

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.

Linux VPS plans

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.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement