Server administrationWritten by GLWS8 min readUbuntu 24.04 LTS / AlmaLinux 9
Commands run on your server unless a section says otherwise. Replace example usernames, addresses and paths with your own values. Keep a working session open when changing remote access.

Find the service you want to manage

Ubuntu 24.04 LTS and AlmaLinux 9 use systemd to manage background services. A service is represented by a unit such as nginx.service. You need sudo access to change its state. Reading status is usually available without it.

Start by finding the exact unit name. A package must be installed before its service exists. Nginx is used below as an example; substitute your installed application's unit. OpenSSH is commonly ssh.service on Ubuntu and sshd.service on AlmaLinux.

List service units
systemctl list-unit-files --type=service
systemctl list-units --type=service --all

Read status before making changes

The Loaded line reports whether systemd found the unit. Active describes its current state. Recent log lines can explain why a start failed. Use --no-pager for output that stays in the terminal, or press q to leave the default pager.

Active and enabled answer different questions. A service can be running now but disabled for the next boot. Conversely, a service can be enabled yet currently stopped or failed. Some short-lived units finish successfully and are then inactive.

Inspect Nginx
systemctl status nginx.service --no-pager
systemctl is-active nginx.service
systemctl is-enabled nginx.service

Start now and enable for boot

Start changes the current running state. Enable arranges normal startup at boot but does not by itself start the service immediately. The --now option performs both operations. Use it only when the service is configured and ready to run.

After enabling a network application, also check its listening address and firewall access. Systemd starting a process does not guarantee that the application responds correctly to clients.

Start now
sudo systemctl start nginx.service
Enable at boot and start now
sudo systemctl enable --now nginx.service
Confirm state
systemctl is-active nginx.service
systemctl is-enabled nginx.service

Choose reload or restart deliberately

Reload asks an application that supports it to reread configuration. Restart stops and starts the process and may interrupt requests. Validate the application's configuration first; Nginx provides nginx -t. A reload can fail if the unit or application does not support it.

Daemon-reload is different: it makes systemd reread unit definitions after a unit file change. It does not replace an application's configuration reload or restart. Avoid experimenting with your SSH service when it is your only way to reach the server.

Validate Nginx before reloading
sudo nginx -t
sudo systemctl reload nginx.service
After editing a systemd unit file
sudo systemctl daemon-reload
RECORDED LAB OUTPUT · Ubuntu 24.04 LTS
active
enabled
active
enabled
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
inactive
Recorded Nginx service checks before and after a reload and a deliberate stop. These are separate command results, not one status response.

Investigate failures and confirm recovery

Inspect the journal before repeatedly restarting a failed service. Look for the earliest relevant error, such as an invalid configuration or occupied port. Fix that cause, retry once, then check status and an actual application request.

To retire a service, disable --now removes normal boot enablement and stops it now. Other units or sockets can still activate it; check dependencies before assuming it is permanently unavailable.

Read recent Nginx logs
sudo journalctl -u nginx.service -b -n 50 --no-pager
Stop and disable only when intended
sudo systemctl disable --now nginx.service

Official documentation

These upstream references provide more detail on the commands and workflows in this guide.