How to Manage Services in Linux (Start, Stop, Enable, Disable)


 Introduction


Services in Linux are background processes that provide essential system functions such as networking, web servers, databases, and more. As a system administrator, you need to know how to manage these services to maintain system stability and performance.



---


Step 1: Check Service Status


On systemd-based systems (modern Linux distros):


systemctl status servicename


➡️ Replace servicename with the service you want to check (e.g., nginx, ssh, mysql).



---


Step 2: Start and Stop a Service


To start a service:


sudo systemctl start servicename


To stop a service:


sudo systemctl stop servicename



---


Step 3: Restart and Reload a Service


Restart the service:


sudo systemctl restart servicename


Reload without stopping (useful for config changes):


sudo systemctl reload servicename



---


Step 4: Enable and Disable a Service


Enable a service to start at boot:


sudo systemctl enable servicename


Disable it from starting at boot:


sudo systemctl disable servicename



---


Step 5: List All Services


View all services and their status:


systemctl list-unit-files --type=service


Or check only active services:


systemctl list-units --type=service --state=running



---


Step 6: Legacy Systems (SysVinit)


On older distributions, use service and chkconfig:


service servicename start

service servicename stop

chkconfig servicename on

chkconfig servicename off



---


Conclusion


Managing services in Linux is essential for keeping your system secure and efficient. With systemctl, you can start, stop, enable, and monitor services easily, while ensuring critical applications are always available.



---

Comments