Questions tagged [systemctl]

Questions about systemctl - the main tool to interact with systemd and the service manager.

Ubuntu systems make use of systemd, which helps to start the system and services on the system. Hereby the systemctl command is the default tool for that issue.

The manual is hosted on freedektop.org and well documented, of course man systemctl works as well.

Before a short list of the most important commands are given some notes. Adding the flag -H user@host to your command allows you to control the systemd on a remote machine. If you do not know the exact name of a unit or command press the Tab key for auto-completion or use pattern matching as described in the bash man page.

In systemd units are the entities of systemd. The 11 different types for units are: service socket target device mount automount timer swap path slice scope. A detailed list and description can be found on systemd.special(7), systemd.service(5) and systemd(1).

systemctl                               # Prints a table of all units
systemctl list-units                    # List all units (where unit is the term for a job/service)
systemctl list-units --type target      # List all target units
systemctl status [PATTERN...|PID...]]   # Show runtime status followed by most recent log data
systemctl list-timers                   # List timer units currently in memory
systemctl list-unit-files --type masked # List all masked unit files

systemctl start [PATTERN...]            # Start (activate) one or more units
systemctl stop [PATTERN...]             # Stop (deactivate) one or more units
systemctl enable [PATTERN...]           # Enable one or more unit files
systemctl disable [PATTERN...]          # Disable one or more unit files
systemctl restart [PATTERN...]          # Restart one or more unit files

systemctl list-jobs [PATTERN...]        # List jobs
systemctl cancel [JOB...]               # Cancel all, one, or more jobs
systemctl reboot                        # Shut down and reboot the system
systemctl poweroff                      # Shut down the system

The complete list of commands is available on systemctl(1).

304 questions
111
votes
5 answers

How to see the latest x lines from systemctl service log

I'm looking for a way, to simply print the last X lines from a systemctl service in Debian. I would like to install this code into a script, which uses the printed and latest log entries. I've found this post but I wasn't able to modify it for my…
user3191334
  • 1,379
  • 2
  • 9
  • 11
46
votes
1 answer

One systemctl command to both start and enable

Using one command to both start and enable systemctl managed software would be useful to spare a few lines in a few scripts, making them a bit more aesthetic (not really a problem but a nice thing to have). Is there one systemctl command to both…
user149572
22
votes
1 answer

pm-suspend vs systemctl suspend?

For Linux distributions using systemd, is there a practical difference between these two commands? systemctl suspend pm-suspend Which should I use or prefer?
Evan Carroll
  • 28,578
  • 45
  • 164
  • 290
21
votes
4 answers

systemd: Can't unmask root mount (-.mount)

(Dist: Debian 10) I have a reoccurring error message that mainly pops up when using systemctl (also when installing a package, and occasionally in a few other places that escape me), Unit -.mount is masked. Sometimes (depending on what command…
ayew
  • 211
  • 2
  • 4
21
votes
1 answer

the --now switch of `systemctl`

As stated in the man page, systemctl --now enable servicename should enable and start the service. But it never works for me, under many different distributions. While the output of: systemctl is-enabled turns enabled, systemctl is-active is still…
user86041
19
votes
3 answers

How to disable CUPS service on reboot with systemd?

I often connect to a network, which has a lot of printers. When printer discovery is ongoing, a lot of distracting messages pop up in GNOME. I use printer only rarely, so I would prefer to keep CUPS disabled most of time. Stopping CUPS works and…
ancient_polaroid
  • 318
  • 1
  • 2
  • 7
15
votes
2 answers

systemctl check if a unit (service or target) exists

I would like to know if a certain systemd unit exists. This should work for: any type of unit (service, target, mount, ...) running, disabled or masked unit I know I could do this: systemctl list-unit-files | grep "^my.target" But it feels like…
Chris Maes
  • 3,282
  • 3
  • 21
  • 32
13
votes
1 answer

Watch systemd service status with systemctl

Is there any option that allow watching the status of a systemd service in real time with systemctl What I actually do: systemctl status tor For example: systemctl watch tor
henriquehbr
  • 818
  • 2
  • 9
  • 28
13
votes
2 answers

Differences between inactive vs disabled and active vs enabled services

I am confused by the concept of enabled or active and disabled or inactive. Could someone explain it?
drpaneas
  • 2,222
  • 8
  • 25
  • 35
12
votes
3 answers

systemctl list all possible (including disabled) services

I have a "service" that originates from an /etc/init.d/XX script, and a systemd wrapper is generated for it. It doesn't autostart in any runlevel, and when I run systemctl --all or systemctl list-unit-files --all it doesn't show up in any list. My…
rogerdpack
  • 1,553
  • 3
  • 15
  • 24
11
votes
1 answer

Have systemd not kill your service if it is in a state it should not be killed

I have a question regarding the configuration of a systemd service. The service application is an application the controls a machine. Within the application the SIGINT, SIGTERM, SIGQUIT and SIGHUP are captured. When the machine is "RUNNING", these…
Jan Jaap
  • 241
  • 1
  • 2
  • 4
10
votes
2 answers

Startup Debian 10 error: networking.service loading failed

I've noticed that every time I turn on my PC, there is a line in red. My PC is pretty fast so I don't get to read the problem. I haven't experienced or noticed any problem with my system, but I'm curious. I've run systemctl --failed and I get the…
George G.
  • 245
  • 1
  • 2
  • 7
9
votes
3 answers

How can I reboot a server with systemctl if systemctl reboot fails?

I tried rebooting my CentOS 7 server but it gives ridiculous error messages. As root (of course): # systemctl reboot Authorization not available. Check if polkit service is running or see debug message for more information. Failed to start…
Ned64
  • 8,486
  • 9
  • 48
  • 86
9
votes
2 answers

Systemctl status always shows full log, even with --lines

I'm trying to get the status of a unit, but only the first 3 lines like this: systemctl --user status resilio-sync --lines=3 I've tried various variations of this with -n 3 etc..., nothing works. And the strange part: it always shows the full log…
Bauglir42
  • 123
  • 1
  • 6
8
votes
1 answer

How should i enable UFW: through "systemctl enable" or "ufw enable"?

I know two ways to start UFW: through systemctl and through ufw itself. For example, when i use systemctl enable ufw, i get this status: systemctl status ufw ● ufw.service - CLI Netfilter Manager Loaded: loaded…
DenisNovac
  • 285
  • 2
  • 3
  • 10
1
2 3
20 21