How to Manually Start and Stop Services in Linux

how to manually start and stop server in linux

While automatic startup handles what happens at boot, system administrators constantly need to manually start, stop, and restart services throughout the day — after a configuration change, during troubleshooting, or to apply an update. This article covers, from first principles, how to manually control services in Linux using systemctl (the modern standard) and legacy service/init.d commands.

What Does “Manually” Mean Here?

“Manual” service control means an administrator explicitly issues a command to change a service’s running state, as opposed to the system automatically doing so at boot or on a schedule. This is the bread-and-butter, everyday task of any Linux admin — applying a config change and testing it live.

sequenceDiagram
    participant Admin
    participant systemctl
    participant Service
    Admin->>systemctl: systemctl start nginx
    systemctl->>Service: Launch process
    Service-->>systemctl: Running
    Admin->>systemctl: systemctl stop nginx
    systemctl->>Service: Terminate process
    Service-->>systemctl: Stopped

The Core systemctl Commands

Starting a Service

sudo systemctl start nginx

This starts the service immediately. It does not affect whether the service starts automatically at the next boot — that’s controlled separately by enable/disable.

Stopping a Service

sudo systemctl stop nginx

Sends a stop signal to the service, letting it shut down gracefully.

Restarting a Service

sudo systemctl restart nginx

Equivalent to a stop followed immediately by a start. Use this after a configuration change that requires a full process restart.

Reloading a Service (Without Full Restart)

sudo systemctl reload nginx

Many services (like Nginx and Apache) support reloading their configuration without dropping active connections — much less disruptive than a full restart. Not all services support this; check with:

systemctl show nginx -p CanReload

Reload-or-Restart

sudo systemctl reload-or-restart nginx

This attempts a graceful reload, but falls back to a full restart if the service doesn’t support reloading.

Checking Service Status

systemctl status nginx

This shows whether the service is active, its process ID, memory usage, recent log lines, and more — the single most useful command for quick diagnostics.

Example output interpretation:

● nginx.service - A high performance web server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
     Active: active (running) since Fri 2026-07-24 09:12:03 UTC; 3h ago
   Main PID: 1423 (nginx)
  • Loaded shows whether the unit file exists and whether it’s enabled for boot
  • Active shows the current runtime state (running, exited, failed, inactive)

Legacy Command: service

Many distributions still support the older service command as a wrapper, which works even on systemd systems for backward compatibility:

sudo service nginx start
sudo service nginx stop
sudo service nginx restart
sudo service nginx status

Internally, on a systemd-based system, this simply calls the equivalent systemctl command.

Legacy init.d Scripts Directly

On very old SysVinit-based systems (or in some minimal/embedded distros), you invoke the init script directly:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/apache2 status

Comparison: Manual Control Commands Across Systems

Actionsystemd (systemctl)Legacy (service)Legacy (init.d direct)
Startsystemctl start svcservice svc start/etc/init.d/svc start
Stopsystemctl stop svcservice svc stop/etc/init.d/svc stop
Restartsystemctl restart svcservice svc restart/etc/init.d/svc restart
Statussystemctl status svcservice svc status/etc/init.d/svc status
Reload config onlysystemctl reload svcservice svc reload/etc/init.d/svc reload

A Practical Walkthrough: Applying a Web Server Config Change

Step 1: Edit the config

sudo nano /etc/nginx/sites-available/mysite.conf

Step 2: Test the syntax before touching the running service

sudo nginx -t

Step 3: Reload gracefully (no dropped connections)

sudo systemctl reload nginx

Step 4: Confirm it’s healthy

systemctl status nginx
curl -I http://localhost

Killing a Stuck Service Manually

Occasionally a service won’t respond to a normal stop command. You can find and terminate its process directly:

systemctl status myapp   # find the Main PID
sudo kill -TERM 4521     # graceful termination request
# if that doesn't work after a few seconds:
sudo kill -KILL 4521     # forceful kill

systemctl stop is always preferred over manually killing processes, since it properly runs the service’s defined stop procedure — manual kill should be a last resort.

Real-World Example: Rolling Restart During Deployment

Suppose you’re deploying a new version of an application behind a load balancer with two backend servers. You want zero downtime:

# On server 1:
ssh server1 "sudo systemctl stop myapp && sudo cp -r /deploy/new-version/* /opt/myapp/ && sudo systemctl start myapp"

# Wait for server1 to pass health checks, then repeat on server2:
ssh server2 "sudo systemctl stop myapp && sudo cp -r /deploy/new-version/* /opt/myapp/ && sudo systemctl start myapp"

This manual, sequential restart pattern (sometimes automated in CI/CD pipelines) avoids taking both servers down simultaneously.

Best Practices

  • Always check status after any start/stop/restart command — don’t assume success just because the command returned without an error message.
  • Prefer reload over restart when a service supports it, to minimize disruption to active connections.
  • Test configuration syntax before restarting, using each service’s built-in test flag (nginx -t, sshd -t, apachectl configtest).
  • Avoid kill -9 (SIGKILL) as a first resort — it doesn’t allow the process to clean up, which can corrupt data (especially for databases). Use systemctl stop first.
  • Check logs immediately if a start fails, using journalctl -u servicename -n 50.
  • Understand the difference between “started” and “enabled.” Starting a service manually does not make it start automatically after a reboot — you must also enable it separately.

Troubleshooting

Problem: systemctl start hangs or times out

The service may be waiting on a dependency (like a database or network mount) that isn’t ready. Check:

journalctl -u servicename -n 50 --no-pager

Problem: Job for nginx.service failed

Run the suggested diagnostic command shown in the error output:

systemctl status nginx.service
journalctl -xe

Problem: Service shows “active (running)” but isn’t actually working

The process may be running but misconfigured (e.g., listening on the wrong port). Check with:

sudo ss -tlnp | grep nginx

Problem: Can’t stop a service — it keeps respawning

Check if it’s configured with Restart=always in its unit file, which will cause it to restart itself even after a manual stop attempt during a crash loop. You may need to systemctl stop immediately followed by fixing the underlying issue, or temporarily mask the service:

sudo systemctl mask servicename

mask prevents the service from being started at all, even manually, until you unmask it.

Problem: “Unit not found” when trying to start a custom service

The unit file may not be recognized yet:

sudo systemctl daemon-reload
systemctl status myapp

Conclusion

Manually starting and stopping services is a daily task for any Linux administrator, and systemctl provides a clean, consistent interface for it across modern distributions — start, stop, restart, reload, and status cover nearly every situation you’ll encounter. Understanding the legacy service and init.d equivalents ensures you’re never stuck when working on an older system. Combined with good habits — testing configs before restarting, checking status after every action, and preferring graceful reloads over hard restarts — manual service management becomes fast, safe, and predictable.

Further Reading

Total
1
Shares

Leave a Reply

Previous Post
how linux boots, about init process working... what run levels in linux

How Linux Boots: The Init Process and Run Levels

Next Post
how to automatically start and stop server in Linux

How to Automatically Start and Stop Services in Linux

Related Posts