Linux provides multiple tools for managing services, each with unique capabilities and use cases. Understanding these tools helps system administrators efficiently control system processes.
graph TD
A[Service Management Tools]
A --> B[systemctl]
A --> C[systemd-analyze]
A --> D[journalctl]
A --> E[chkconfig]
Basic Systemctl Commands
Command |
Function |
Example |
start |
Start a service |
sudo systemctl start nginx |
stop |
Stop a service |
sudo systemctl stop apache2 |
restart |
Restart a service |
sudo systemctl restart mysql |
status |
Check service status |
systemctl status ssh |
enable |
Enable service at boot |
sudo systemctl enable firewalld |
disable |
Disable service at boot |
sudo systemctl disable cups |
## Show system boot time
systemd-analyze
## Detailed service startup time
systemd-analyze blame
## Identify critical path during boot
systemd-analyze critical-chain
Journalctl: Log Management
## View system logs
journalctl
## View logs for specific service
journalctl -u nginx.service
## View logs from current boot
journalctl -b
1. Chkconfig (Legacy Systems)
## List services
chkconfig --list
## Enable service
chkconfig servicename on
## Disable service
chkconfig servicename off
2. Service Command
## Start a service
sudo service nginx start
## Stop a service
sudo service apache2 stop
## Restart a service
sudo service mysql restart
Advanced Service Management
Masking Services
## Completely disable a service
sudo systemctl mask bluetooth.service
## Unmask a service
sudo systemctl unmask bluetooth.service
LabEx Tip
Explore these service management tools in a LabEx environment to gain practical experience without risking your primary system configuration.
Best Practices
- Use
systemctl
as the primary management tool
- Regularly monitor service logs
- Understand each tool's specific use case
- Keep services minimal and secure
Troubleshooting Services
## Check for failed services
systemctl --failed
## Verify service configuration
systemctl verify nginx.service