Linux Commands / IT Support Guides
Inspect a systemd service before restarting it
Check whether a systemd service is running now and whether it is enabled to start automatically.
Environment and inputs: Linux · Bash-compatible shell; package and service names vary by distribution
Understand the problem
Use a Linux host with systemd. Replace nginx with the unit you support, such as nginx.service if that is its full name.
Run the command
Run systemctl status first to see the current state and recent messages. Then run systemctl is-enabled to check the unit’s enablement state.
systemctl status nginx --no-pager
systemctl is-enabled nginx
Read the output
Active: active (running) means the service process is up. An enabled result means the unit has startup links configured. A service may be running now even if it is disabled.
Choose the next step
If the status is failed, read the first relevant error and check the unit log around that time. If the unit cannot be found, verify its name and whether the service is installed.
Before making changes
Save the state, timestamp, and relevant error before changing the service. A running process can still be unhealthy, so verify that the application responds as expected.