Skip to main content
217 votes
Accepted

How to see the latest x lines from systemctl service log

journalctl --unit=my.service -n 100 --no-pager
sourcejedi's user avatar
  • 51.4k
73 votes
Accepted

One systemctl command to both start and enable

Yes, there is, since systemd 220 (May 2015): systemctl enable --now This will enable and start the named units. See the systemctl manpage for details.
Stephen Kitt's user avatar
48 votes

How to see the latest x lines from systemctl service log

If you want to see the last n number of lines and see new messages as they are printed to the log, try this: journalctl -u <service name> -n <number of lines> -f Where -n indicates the ...
Derek Soike's user avatar
34 votes

How to see the latest x lines from systemctl service log

Just: journalctl -u SERVICE_NAME -e Parameter -e stands for: -e --pagerend; Immediately jump to the end of the journal inside the implied pager tool. This implies -n 1000 to guarantee that the ...
Daniel's user avatar
  • 441
32 votes
Accepted

pm-suspend vs systemctl suspend?

In short, you should generally prefer the suspend mode integrated by your distro. For distros that ship systemd, that's typically systemctl suspend. For instance, the Arch Linux wiki says: systemd ...
filbranden's user avatar
  • 22.1k
30 votes
Accepted

the --now switch of `systemctl`

I've found that annoying as well. Looks like the --now switch was added in version 220 (see this line in the changelog), and CentOS 7 is currently on version 219. Hopefully soon then! You can check ...
David Birks's user avatar
27 votes
Accepted

How to disable CUPS service on reboot with systemd?

No, activation does not happen because of preset. systemctl disable cups will only prevent it from auto-starting. It's possible that it was started anyway because it was required for another service....
Joseph Tingiris's user avatar
23 votes

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

I was getting the same while performing step 6 in this answer: https://askubuntu.com/a/1028709/1003629. By trial and error I found this was no longer an issue if I closed GParted. Edit after I got ...
pateksan's user avatar
  • 333
19 votes
Accepted

Watch systemd service status with systemctl

You could use the watch command to watch the output of systemctl status tor: watch systemctl status tor You can also follow the systemd logs for the service, which may also be useful: journalctl -u ...
rusty shackleford's user avatar
17 votes
Accepted

How to remove service from autostart?

If your system has both: chkconfig service off systemctl disable service RHEL5 uses chkconfig by default. On a side note, I recommend upgrading because RHEL 5 has been EOL since March 31st, 2017 ...
Nasir Riley's user avatar
  • 11.7k
16 votes

How to see the latest x lines from systemctl service log

You could pipe the output to tail: journalctl --unit=my.service | tail -n 300 The tail command prints the last lines (10 by default) received in stdin to stdout. Edit: as noted in the comments, this ...
dr_'s user avatar
  • 30.4k
16 votes

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

If Zach Sanchez' answer doesn't work (I got Failed to start reboot.target: Connection timed out for my systemctl --force reboot in a strange situation under CentOS 7) making the kernel basically crash ...
Paul's user avatar
  • 261
14 votes
Accepted

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

The command systemctl status display the status of the service and the corresponding lines from journalctl, the --lines=3 will limit the displayed number of lines from the journal to 3. e,g: systemctl ...
GAD3R's user avatar
  • 67.7k
14 votes
Accepted

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

As weird as it may seem, trying running systemctl --force --force reboot It has popped up in a couple of searches I made. It may be related to issues with a DBus service restarting. Can't reboot. ...
Zach Sanchez's user avatar
13 votes
Accepted

redhat 7 + How to stop systemctl service permanent

systemctl disable servicename. Running systemctl disable removes the symlink to the service in /etc/systemd/system/*. From now on, that service won't start on boot anymore.
steve's user avatar
  • 22.1k
13 votes
Accepted

What does Restart=on-abort mean in a systemd service?

The systemd.service can be configured to restart a service based on a number of conditions. This systemctl man page has a good explanation of the reasons and reasons are included in this answer so ...
PatS's user avatar
  • 624
11 votes
Accepted

Show journal logs from the time a service was restarted

You can use the invocation id, which is a unique identifier for a specific run of a service unit. It was introduced in systemd v232, so you need at least that version of systemd for this to work. To ...
filbranden's user avatar
  • 22.1k
11 votes

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

This answer is primarily based on the documentation for systemd.kill, but has been updated after doing some tests. It is admittedly not a perfect solution to this problem. By setting SendSIGKILL=no ...
Haxiel's user avatar
  • 8,491
11 votes
Accepted

systemctl list all possible (including disabled) services

OK I asked "the systemd guys" and they said in old versions it didn't list them all, despite the man page saying this: -a, --all When listing units, show all loaded units, regardless of ...
rogerdpack's user avatar
  • 1,777
11 votes

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

You could try removing the -.mount sudo rm /run/systemd/system/-.mount and then reloading systemd sudo systemctl daemon-reload
reubot's user avatar
  • 111
11 votes
Accepted

What are these > at the right of unterminated lines, when I do a systemctl status or a journalctl for example?

You can see the full text using the Right Key (>) of your keyboard. If I'm not wrong when you use some commands like journalctl options..., systemctl options... these page their output through less ...
Edgar Magallon's user avatar
10 votes

redhat 7 + How to stop systemctl service permanent

There is also a stronger version of the disable command, which is mask. From the manual: mask UNIT… Mask one or more units, as specified on the command line. This will link these unit files to ...
Haxiel's user avatar
  • 8,491
10 votes

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

If you do ufw enable, systemctl disable ufw and then reboot the system, what is the ufw status verbose output after the reboot? I'm guessing that it will be inactive. If that's true, then the ...
telcoM's user avatar
  • 102k
10 votes
Accepted

Reason for processing `systemctl status` via command substitution?

There’s no reason, other than possibly ignoring systemctl’s exit status (that would depend on the surrounding setup). There might be historical factors explaining why the command is written that way, ...
Stephen Kitt's user avatar
9 votes

systemctl list all possible (including disabled) services

List every loaded service that is running, active, or failed in the system: # sudo systemctl list-units --type=service --all List all Disabled services in the system: # sudo systemctl list-unit-files ...
Namasivayam Chinnapillai's user avatar
9 votes

Systemd auto restart service not working if it stopped

The Restart setting doesn’t work like that; quoting the manual, When the death of the process is a result of systemd operation (e.g. service stop or restart), the service will not be restarted. ...
Stephen Kitt's user avatar
8 votes

How to disable CUPS service on reboot with systemd?

The cups package ships three systemd unit files: cups.service, cups.socket and cups.path. The latter two are used for socket activation and path activation, which will end up triggering the service ...
filbranden's user avatar
  • 22.1k
8 votes

Will a systemd service automatically manage it's logs (do log rotation etc)

According to the systemd documentation, the logs kept by journald default to a size limit of 15% of disk capacity or 4GB, whichever is smaller. If /var is not mounted, not writable, or /var/log/...
gnubeard's user avatar
  • 319
8 votes
Accepted

Run a binary file via systemctl

In order to run a binary as service you can follow these steps: Write a service file named MFBot_Konsole.service: [Unit] Description=MFBot_Konsole After=network.target [Service] Type=simple ...
iLuvLogix's user avatar
  • 210

Only top scored, non community-wiki answers of a minimum length are eligible