How to Restart a Background Service in Ubuntu Linux Terminal

When you modify a configuration file for a background service in Ubuntu Linux (such as the Apache web server, the SSH daemon, or a database), the changes do not take effect immediately. The service is already running in the system memory using the old configuration. To force the software to read your new settings, you must restart the service using the terminal. Ubuntu utilizes systemd as its initialization system, which means you will primarily use the systemctl command to manage these services.

How to Restart a Service Using systemctl

The standard, modern method for managing services in Ubuntu is the systemctl command. Because restarting a system service affects all users and core functionality, you must execute the command with administrator privileges using sudo.

The syntax is simple: sudo systemctl restart [service_name]

For example, if you just updated your firewall rules and need to restart the Uncomplicated Firewall (UFW) service, you would open your terminal and type:

sudo systemctl restart ufw

Press Enter. The system will prompt you for your user password. Once entered, the terminal will usually return to the prompt without displaying any confirmation text. In Linux, no news is generally good news—it means the command succeeded.

How to Verify the Service Restarted Successfully

Because the restart command doesn’t provide visual feedback, it is best practice to immediately check the status of the service to ensure it didn’t crash while trying to read your new configuration file.

Use the status command:

sudo systemctl status [service_name]

For example: sudo systemctl status ufw

This command will output a block of text. Look for the line that says Active:. It should say active (running) in green text. You can also look at the line below it, which will tell you exactly how many seconds or minutes ago the service was started, confirming your recent restart.

Restart vs. Reload: Which Should You Use?

While restart is the most common command, it completely kills the process and starts it up again from scratch. If you are restarting a busy web server (like Nginx or Apache), this hard reset will abruptly drop any active connections users have to your website.

Many modern services support a gentler command called reload.

sudo systemctl reload nginx

The reload command tells the service to stay running, keep all active user connections open, but secretly re-read the configuration file in the background and apply the changes to new connections. Whenever possible, you should try to reload a production service rather than restart it. If a service does not support reloading, the terminal will give you an error, and you must use restart instead.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.