Managing systemd services in Linux
You will learn how to start, stop, or restart services in Linux. You will learn how to manage services through the systemd daemon using the systemctl command, using the service command, and using init scripts in the /etc/init.d directory. You will need administrator privileges.
Managing services using systemd and the systemctl command
Since Linux switched to managing services with the systemd daemon, this has become the preferred way to manage services in current Linux versions.
To start a service, enter the following in the console:
sudo systemctl start <service_name>To stop a service, enter the following in the console:
sudo systemctl stop <service_name>To restart a service, enter the following in the console:
sudo systemctl restart <service_name>To check the status of a service in the console, enter:
sudo systemctl status <service_name>Managing services using the service command
To start a service, enter the following in the console:
sudo service <service_name> startTo stop a service, enter the following in the console:
sudo service <service_name> stopTo restart a service, enter the following in the console:
sudo service <service_name> restartTo check the status of a service in the console, enter:
sudo service <service_name> statusManaging services using init.d scripts
This method is outdated and was used before Linux switched to managing services with the systemd daemon. For this reason, it is only used on older versions of Linux. It works by running a script located in the /etc/init.d directory.
To start a service, enter the following in the console:
sudo /etc/init.d/<service_name> startTo stop a service, enter the following in the console:
sudo /etc/init.d/<service_name> stopTo restart a service, enter the following in the console:
sudo /etc/init.d/<service_name> restartTo check the status of a service in the console, enter:
sudo /etc/init.d/<service_name> statusComments (0)
No comments yet.
Add a comment
Comments are published after moderation. Your e-mail address stays private.