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.
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.
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/
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.
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
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
- 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.