systemctl is a command-line utility used to interact with the systemd system and service manager in Linux. It is used for managing system services, controlling the system state, and managing system resources. Here are some key functions of systemctl:
-
Start and Stop Services:
- Start a service:
sudo systemctl start <service_name> - Stop a service:
sudo systemctl stop <service_name>
- Start a service:
-
Enable and Disable Services:
- Enable a service to start at boot:
sudo systemctl enable <service_name> - Disable a service from starting at boot:
sudo systemctl disable <service_name>
- Enable a service to start at boot:
-
Check Service Status:
- Check if a service is running:
systemctl status <service_name>
- Check if a service is running:
-
List Services:
- List all active services:
systemctl list-units --type=service --state=active - List all services regardless of their state:
systemctl list-units --type=service --all
- List all active services:
-
Manage System State:
- Reboot the system:
sudo systemctl reboot - Power off the system:
sudo systemctl poweroff
- Reboot the system:
-
View Logs:
- View logs for a specific service:
journalctl -u <service_name>
- View logs for a specific service:
systemctl is a powerful tool for managing services and system states in modern Linux distributions that use systemd as their init system.
