You can check if a service is running using the systemctl command in Linux. Here’s how to do it:
Open a terminal.
Use the following command to check the status of the service. Replace
service_namewith the actual name of the service you want to check (e.g.,sshdfor SSH service,apache2for Apache web server):systemctl status service_name
For example, to check the status of the SSH service, you would run:
systemctl status sshd
- Interpreting the output:
- Look for the line that starts with
Active:. If it saysactive (running), the service is running. - If it says
inactiveorfailed, the service is not running.
- Look for the line that starts with
Alternatively, if you want to check if a specific port (like 8000) is being listened to, you can use:
netstat -tuln | grep :8000
This will show if any service is listening on port 8000. If there is output, it means a service is running on that port. If there is no output, then nothing is listening on that port.
