sysdemd
systemd is the init system used by most, but not all, Linux-based operating systems.
systemd does a lot of things, and a short synopsis of its features is difficult. It handles boot initialization, processes, and various other system configuration items.
Processes are managed in groups called units.
Application management
Application/process management
Mostly we use the systemctl command to control units or the system itself. This is especially useful for managing important background processes like server daemons, including ssh.
| Command |
Explanation |
| systemctl list-units |
List units on the system |
| systemctl status sshd |
Get information about the sshd unit |
| systemctl restart sshd |
Restart sshd unit (stop and immediately start again) |
| systemctl stop sshd |
Stop the sshd unit (careful here if you only have remote access via ssh) |
| systemctl disable sshd |
Prevent the sshd unit from starting when the system boots |
| systemctl enable sshd |
Enable the sshd service so it can be run on every boot |
See below for troubleshooting a unit.
Troubleshooting
The journalctl command lets you access log information.
| Command |
Explanation |
| journalctl -f |
Kind of similar to a command like tail -f /var/log/example.log. the -f means follow |
| journalctl -b |
Retrieves logs from current boot |
| journalctl -b -1 |
Using a boot offset, -1 would show you the prior butt and -3 would show you -3 boots ago (default is boot 0, the current boot) |
| journalctl --list-boots |
Get a list of prior boots |
| journalctl --since "1 hour ago" |
Get log data from the past hour. |
| journalctl --since "2025-06-26 22:00:15" --until "2025-06-28 23:59:59" |
Log data over a time range, format YYYY-MM-DD HH:00:SS, but other formats are possible |
| journalctl -n 25 --since "1 hour ago" |
Show the last 25 log invents in the past hour |
| journalctl -r -n 25 --since "1 hour ago" |
Show the last 25 log invents in the past hour, but reverse the order (-r flag) |
If you want to troubleshoot a unit, you can use more specific commands similar to the above. Using the NetworkManager.service unit as an example:
| Command |
Explanation |
| journalctl -u NetworkManager.service |
Look at NetworkManager logs |
| journalctl -u NetworkManager.service -f |
Tail the log for NetworkManager in your console |
| journalctl -u NetworkManager.service -u sshd.service |
Look at logs for two units, this this case both NetworkManager and the SSH server |
You can adapt a lot of the parameters in the first section to the per-unit commands.
|