14 C
Texas
angeloma
Senior Writer and partner

The Linux systemctl command

In many of our tutorials we have to manage services but what are these services? How are they handled? Well, basically they can be handled with the systemctl command. And in this post, I will teach you how to use the Linux systemctl command. At least so that you can manage the computer services in a fast and basic way.

What is a system service?

A system service is usually an application that runs in the background. That is to say that it is not necessary that they have a constant interaction with the user to be able to work. This concept is vital to any modern operating system. Some of the most essential applications of a server are managed as services, for example, SSH or MySQL.

Well, services are handled in Linux with a command that is systemctl. This is because, since recent versions of the kernel and the main current Linux distributions, Systemd is in charge of managing the services.

So we will see how to use the Linux systemctl command.

The Linux systemctl command

- Advertisement -

Within our Linux system, the main function of the systemctl command is to administer the system services. Or those applications that are managed as a service.

First, it is a command that requires root privileges to function. This means that either we enable sudo for our user or we will have to be the root user.

How to enable sudo on Debian 10?

How to enable sudo on CentOS 8?

Now, we will be able to list all the services that are in our system, for it uses the following command

:~# systemctl -t list-unit-files --all

It is also useful to list all active services. To do this, just use:

:~# systemctl list-unit

Once we know what the services are, we can work with them.

To start a service that is stopped the syntax is as follows:

:~# systemctl start [service_name]

For example:

:~# systemctl start apache2

To stop it:

:~# systemctl stop [service_name]

Sometimes we make changes to the service and for them to take effect it is necessary to restart it. To do this, we use the following command:

~# systemctl restart [service_name]

However, many of these changes are at the configuration level. In this case, the service has to be recharged.

:~# systemctl reload [service_name]

It is also possible to restart a service that is currently running:

:~# systemctl condrestart [service_name]

And if you want to know the status of a service:

:~# systemctl status [service_name]

This function is quite interesting about the status of the service. Because we will be able to have in detail if a service is running or not. And if at the moment of initiating it gives an error, also with this command we will be able to make the pursuit of him.

If you want a service to run automatically with the system, you can do it with the following command:

:~# systemctl enable [service_name]

If you no longer wish it to be so, reverse it with this other command:

:~# systemctl disable [service_name]

And that is it. I hope this little guide can help you with systemctl.

Conclusion

Using and managing the system’s services on Linux is not a completely simple task, but it is not as difficult as we think. In this sense, systemctl is a relatively simple command that will help us with the management of them.

Please share this post, with your friends and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article