How to Restart a Service in Linux?
Everything which is executed or is running on a Linux machine is linked to a service. In many cases, we come across situations when we have to restart those services. Those situations could be like service is using too much RAM memory or consuming a lot of CPU or the service is malfunctioning or could be any other situation for testing purposes. So, in order to do that we have to follow the procedure which is given below.
Flowchart of the process
The very first step is to open the terminal and look for the service to restart. Then just fire a command to restart the service and the service will stop and start again.
To do it practically
1. Open the terminal:
All the Linux distributions have an application menu, so just look for the terminal there and open the same. After finding the terminal, just click on the app icon to open it. In many Linux, the terminal will be at the top or bottom of the screen in the application dock.
2. Displaying the running service:
So to display the current running service just type the following command.
So typing this will give you all the services that are running currently.
3. Services you want to restart:
So just select the service you want to restart, you will generally find the service you want to restart on the left side of the screen(it depends on your Linux distribution). For instance let it be “apache2”
4. Restarting your service:
So Basically at this stage, you have selected the service you want to restart.So type the following command to restart the service
sudo systemctl restart apache2
5. Entering Authentication Details:
Type in the password of your linux user account then as soon as you press enter the service would be restarted.
So if the above method didn’t work then just type the following command
sudo systemctl stop service
Then press Enter, this will stop your service. Then enter the following command to start the service again.
sudo systemctl start service
This will start your service again.