Lesson 3.9: Start, stop, and check the status of network services
To Check the status of a service
systemctl status <service name>
[root@sanjeeb ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; pres> Active: active (running) since Wed 2024-09-25 20:39:11 +0545; 24min > Docs: man:httpd.service(8) Main PID: 1313 (httpd) Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0;> Tasks: 177 (limit: 22585) Memory: 36.3M CPU: 3.452s CGroup: /system.slice/httpd.service ├─1313 /usr/sbin/httpd -DFOREGROUND ├─6199 /usr/sbin/httpd -DFOREGROUND ├─6200 /usr/sbin/httpd -DFOREGROUND ├─6201 /usr/sbin/httpd -DFOREGROUND └─6202 /usr/sbin/httpd -DFOREGROUND Sep 25 20:38:46 sanjeeb systemd[1]: Starting The Apache HTTP Server... Sep 25 20:38:59 sanjeeb httpd[1313]: AH00558: httpd: Could not reliably d> Sep 25 20:39:11 sanjeeb httpd[1313]: Server configured, listening on: por>
To start a service
systemctl start <service name>
[root@sanjeeb ~]# systemctl start httpd
To start and stop a service in next reboot
- To Start in next reboot :
systemctl enable <service name>
- To Stop in next reboot :
systemctl disable <service name>
To check the opened ports
[root@sanjeeb ~]# netstat -tnl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:47569 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::47571 :::* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN
Restarting the Service
Restarting a service will follow the commands systemctl stop <service name>
, and the systemctl start <service name>
.
systemctl restart <service name>
Reloading the Service
Reloading a service will not stop the service, it will reload without making effect to the running process
systemctl reload <service name>