Systemctl is a system utility in the Linux operating system that is used to manage services or daemons. It is one of the main utilities in systems that use the systemd
init system
. Systemd
is a tool for managing processes and services, and includes the init systemd, unit manager, and other components.
The systemctl
utility in Linux is the main tool for managing services on the system and is responsible for the following tasks:
"systemctl start apache2
" will start the Apache web server and"systemctl stop apache2
" will stop it."systemctl restart apache2
" will restart the Apache web server."systemctl status apache2
" will provide information about the status of the Apache web server, such as whether it is active, what ports it is listening on, and other debugging information."systemctl enable apache2
" will enable the Apache web server to start automatically every time the system boots.To use systemctl, you will need access to the Linux command line. Here are some basic commands and how to use them:
systemctl start <service>
- The command allows you to start the specified service. To start the Apache HTTP Server service, you need to run systemctl start apache2
.systemctl stop <service>
- the command stops the specified service. systemctl stop apache2
will stop Apache HTTP Server.restart <service>
- restart. systemctl restart apache2 will restart the Apache HTTP Server.systemctl reload <service>
- restarts the service. The difference between restarting and reloading is that restarting stops and then starts the service again, while reloading restarts it, without completely stopping it.systemctl status <service>
- the command shows the current status of the specified service.Next, let's talk about configuring the service.
The main commands to configure and use systemctl
.
Starting the service:
sudo systemctl start <service_name>
Stopping the service:
sudo systemctl stop <service_name>
Restarting the service:
sudo systemctl restart <service_name>
Enabling service autorun on system boot:
sudo systemctl enable <service_name>
Disabling service autorun on system boot:
sudo systemctl disable <service_name>
Checking the status of a service:
sudo systemctl status <service_name>
Viewing a list of all available services:
sudo systemctl list-unit-files --type=service
Viewing the service log:
sudo journalctl -u <service_name>
Viewing the most recent system log entries:
sudo journalctl -xe
Rebooting the system:
sudo systemctl reboot
Shutting down the system:
sudo systemctl poweroff
Remember that you may need superuser (sudo) privileges to run the systemctl
commands. Make sure you specify the correct service name when using these commands.