Listen to this post |
Learn systemctl
The Basics
The systemctl command on most Linux distributions controls your system. I’m writing this article to explain using systemctl and journalctl. I’ve used the service command in the past, but it has gone out of style. It’s time for an update.
Without systems, the systemctl and journalctl commands would not exist. The systemd software suite aims to unify service configuration and behavior across systems. It’s worth noting that people dislike systemd because it enables tight couplings between software packages and systemd.
Primary Use Cases
- Managing services on Unix systems
- Container manager interface
Invalid Use Cases
- A dependency required to run your software
Common Commands
# List all services
sudo systemctl list-units --type service
# List running services
sudo systemctl list-units --type=service --state=running
# List active services
sudo systemctl list-units --type=service --state=active
# Get the status of a service
sudo systemctl status containerd
# Stop a service
sudo systemctl stop containerd
# Start a service
sudo systemctl start containerd
# Restart a service
sudo systemctl restart containerd
# Check if a service is active
systemctl is-enabled containerd
# Disable a service is active
systemctl disable containerd
# Check if ssh is active
sudo systemctl is-active containerd
# Check service logs for current boot sequence
journalctl -u service-name.service -b
# Check service logs
journalctl -u containerd
# Tail service logs
journalctl -u containerd -f