Categories: LinuxShellUbuntu

How to Start, Stop or Restart Services in Ubuntu

As with all other operating systems, Linux has services and other processes that run in the background to perform certain important functions while the system is running. When the system is booted, the services start automatically and continue to run in the background until the system is shut down. However, you can also start, stop and restart the services manually.

In this article, I'll show you different methods for starting, stopping, and restarting services in Ubuntu. The article covers systemd, the service command, and init scripts. These commands work on all current versions of Ubuntu, including the new Ubuntu 22.04.

List all services in Ubuntu

Before we start, I will show you how to get a list of all the services on your computer as we need to know the service name to manage the service.

service --status-all

It will show a complete list of services on Ubuntu.

Use Systemd to Start/Stop/Restart Services in Ubuntu

You can start, stop or restart services using Systemd systemctl utility. This is the preferred way on current Ubuntu versions like Ubuntu 18.04, Ubuntu 20.04, and Ubuntu 22.04.

Open up a terminal window, and enter the following commands. For instance, in this case, I want to start, stop or restart the UFW Firewall service in Ubuntu.

The Syntax is:

sudo systemctl [action] [service name]

To start a service:

sudo systemctl stop ufw

To stop a service:

sudo systemctl start ufw

To restart a service:

sudo systemctl restart ufw

To check the status of service:

sudo systemctl status ufw

Start/Stop/Restart Services with service command on Ubuntu

You can start, stop, or restart services using the service command too. Open up a terminal window, and enter the following commands.

To start a service:

sudo service ufw stop

To stop a service:

sudo service ufw start

To stop a service:

sudo service ufw restart

To check the status of a service:

sudo service ufw status

Using Init scripts to manage services on Ubuntu

You can start, stop or restart services using init scripts in the /etc/init.d directory. This directory actually consists of various scripts for different services. Init scripts are deprecated since Ubuntu switched to Systemd, so this method will be used only if you have to deal with an old Ubuntu version. Open up a terminal window, and enter the following commands.

To start a service:

/etc/init.d/ufw start

To stop a service:

/etc/init.d/ufw stop

To stop a service:

/etc/init.d/ufw restart

To check the status of service:

/etc/init.d/ufw status

That is how you can start, stop, and restart services using different ways without restarting the whole operating system. You can also use these commands in other Linux distributions.

Vitux Staff

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago