How to Check Service Status on Linux: Simple Commands
To check the status of a service on Linux, use the
systemctl status servicename command on systems with systemd. On older systems, use service servicename status to see if the service is running.Syntax
There are two common commands to check service status on Linux:
systemctl status servicename: Shows detailed status of the service using systemd.service servicename status: Works on older init systems to show if the service is running.
Replace servicename with the actual name of the service you want to check.
bash
systemctl status servicename service servicename status
Example
This example checks the status of the ssh service using systemctl. It shows if the service is active and running.
bash
systemctl status ssh
Output
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-06-14 10:00:00 UTC; 1h 30min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 1234 (sshd)
Tasks: 1 (limit: 4915)
Memory: 2.0M
CGroup: /system.slice/ssh.service
└─1234 /usr/sbin/sshd -D
Common Pitfalls
Common mistakes when checking service status include:
- Using
serviceon systems that usesystemctl, which may not work or show limited info. - Not running the command with sufficient permissions; some services require
sudo. - Misspelling the service name, which leads to errors or no output.
Always verify the service name and use sudo if needed.
bash
service ssh status sudo systemctl status ssh
Quick Reference
| Command | Description |
|---|---|
| systemctl status servicename | Show detailed status of a service on systemd systems |
| service servicename status | Check service status on older init systems |
| sudo systemctl status servicename | Run with admin rights if permission denied |
| systemctl is-active servicename | Show if service is active (running) or not |
Key Takeaways
Use 'systemctl status servicename' to check service status on modern Linux systems.
Use 'service servicename status' on older Linux systems without systemd.
Run commands with 'sudo' if you get permission errors.
Always use the correct service name to get accurate status.
Use 'systemctl is-active servicename' for a quick active/inactive check.