Services in Linux: How to Start, Stop, and Restart Them?

Services in Linux: How to Start, Stop, and Restart Them?

Linux systems work so seamlessly because of services. These keep working on the background continuously and process the incoming requests from clients. There are a wide range of system services and network services. When there’s a group of services working together, they’re collectively called daemons. You never get to interact with them since they lack an interface. But they’re vital to functioning of a Linux system. In this article, learn how to list all the system on your Linux system and how to start, stop, or restart them.

List, Start, Stop, Restart Services with Systemctl

To work with services, you can either use Systemctl or Init. Let’s first use Systemctl. Here are the steps you need to follow:
  • Open the terminal
  • Start with listing all the services your Linux system has by executing the below command in the terminal:
Code:
sudo systemctl list-unit-files --type service --all
  • Not all services will be running at present. To list the ones that are running, use this command and combine them with grep:
Code:
sudo systemctl ¦ grep running
  • To start a service, reference to that inactive service and execute this command:
Code:
systemctl start <service-name>
  • To stop a service, use the stop option flag and execute this command:
Code:
systemctl stop <service-name>
  • To restart a service, execute this command:
Code:
systemctl restart <service-name>
  • You can check the status of any service, by executing this command:
Code:
systemctl status <service-name>
List, Start, Stop, Restart Services with Init

You can use init for this purpose. Here are the steps to be followed:
  • To list all the services in the Linux web server, execute this command:
Code:
service --status-all
  • It will show up a list of services. Those that are disabled will have a [-] sign next to them. And the services that are enabled will have the [+] sign next to them
  • To start a disabled service, execute the following command:
Code:
service <service-name> start
  • To stop a service, execute this command:
Code:
service <service-name> stop
  • To restart a service, execute this command:
Code:
service <service-name> restart
  • Don’t restart the entire web service. Instead, restart only those services that are appropriate for the changes to come into effect.
  • To check the status of a service, execute this command:
Code:
service <service-name> status
So that’s how you work with Linux services. Regularly checking for services will keep your web server safe. Often times, hackers will inject codes that will run harmful services in the background. You must get rid of them at the earliest. For more assistance, get in touch with the hosting support team.
Author
kumkumsharma
Views
167
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top