How to restart services on Linux: 5 steps

Table of contents:

How to restart services on Linux: 5 steps
How to restart services on Linux: 5 steps
Anonim

This article will show you how to force restart a service (service) in Linux. This can be done with a few simple commands on any Linux distribution.

Steps

Restart Services in Linux Step 1
Restart Services in Linux Step 1

Step 1. Open a terminal

Most Linux distributions have a menu (in the lower left corner of the screen) that contains the Terminal application. Terminal is analogous to the Windows command line.

  • The user interface depends on the Linux distribution, so you may have to find the Terminal application inside one of the menu folders.
  • It is possible that the Terminal application icon will be on the desktop or in the toolbar at the bottom of the screen, rather than in the Menu.
  • On some Linux distributions, the terminal line appears at the top or bottom of the screen.
Restart Services in Linux Step 2
Restart Services in Linux Step 2

Step 2. Enter the command to display a list of all active services

Type ls /etc/init.d in a terminal and press ↵ Enter. The screen displays a list of running services and the corresponding command names.

If this command did not work, enter ls /etc/rc.d/

Restart Services in Linux Step 3
Restart Services in Linux Step 3

Step 3. Find the command name of the service you want to restart

Typically, the service name (for example, “Apache”) appears on the left side of the screen, and the command name (for example, “httpd” or “apache2” depending on your Linux distribution) appears on the right side of the screen.

Restart Services in Linux Step 4
Restart Services in Linux Step 4

Step 4. Enter the command to restart the service

Type sudo systemctl restart service in a terminal, substitute the service command name for service, and then press ↵ Enter.

For example, to restart Apache on Ubuntu, type sudo systemctl restart apache2 in a terminal

Restart Services in Linux Step 5
Restart Services in Linux Step 5

Step 5. Enter your password when prompted

Enter the superuser password, then press ↵ Enter. The service will be restarted.

If the service does not restart, type sudo systemctl stop service, press ↵ Enter, and then type sudo systemctl start service

Advice

  • Using the "chkconfig" command, you can add and remove a service from the startup list.
  • To see a list of absolutely all active services (in all directories), enter ps -A in a terminal.

Popular by topic