What Is The Systemctl Command On Linux?

A tool used in Linux operating systems to manage system services and regulate general system behaviour is the systemctl command. It enables users to activate, disable, start, stop, restart, and check the status of a number of system services, including Apache, SSH, MySQL, and others. The programme also offers details on system activities, logs, and error messages to assist users in resolving issues and preserving system stability. Overall, systemctl is a strong and useful utility for Linux users and system administrators.

The basic syntax of systemctl command

systemctl [options..] command [unit..]

Example of sysemctl command

1. How to start any service using systemctl command?

The steps below can be used to start a service using the systemctl command:

On your Linux computer, launch a terminal.
Enter the name of the service you wish to start, followed by systemctl start. For instance, you might enter systemctl start apache2.service to launch the Apache web server.
Enter is required to carry out the command. If the service launches properly, a confirmation message ought to appear in the terminal.
As an alternative, you may enter systemctl start <service_name> to use the abbreviated version of the command. You can use this command to launch any service that has been set up to function on your system.

It is crucial to remember that launching a service using systemctl needs administrative rights as a result, if you are not logged in as the root user, you might need to use sudo before the command.

sudo systemctl apache2.service
Here is a practical example of systemctl command:

2. How to check status any service using systemctl command?

You can do the following actions to determine a service’s status:

On your Linux computer, launch a terminal.
Enter the name of the service you wish to check the status of, followed by systemctl status. For instance, you might enter systemctl status apache2.service to check the status of the Apache web server.
Enter is required to carry out the command. The status of the service will be shown on the terminal, including if it is active, whether any faults have been encountered, and when it was last started or terminated.
As an alternative, you may enter systemctl status <service_name> to utilise the command’s abbreviated form. Every service that is set up to operate on your system may be checked to see how things are doing with this command.

sudo systemctl start apache2.service
Here is a practical example of systemctl command:

3. How to start a service at boot time using systemctl command?

The following steps can be used to start a service using the systemctl command at boot time:

On your Linux computer, launch a terminal.
To enable a service at boot time, use sudo systemctl enable followed by its name. For instance, you might execute sudo systemctl enable apache2.service to enable the Apache web server at startup time.
Enter is required to carry out the command. By doing this, a symbolic link will be created in the proper systemd target directory, enabling the service to launch upon boot.
As an alternative, you can use sudo systemctl enable <service_name> to utilise the command’s abbreviated form. Any service that is set to launch at system startup can be enabled with this command.

sudo systemctl enable apache2.service
Here is a practical example of systemctl command:

4. How to stop a service at boot time using systemctl command?

You can take the following actions to use the systemctl command to prevent a service from starting up at boot time:

On your Linux computer, launch a terminal.
To disable a service at boot time, use sudo systemctl disable followed by its name. You might execute sudo systemctl disable apache2.service, for instance, to prevent the Apache web server from starting at startup time.
Enter is required to carry out the command. This will disable the service from running at boot time by removing the symbolic link in the relevant systemd target directory.
By entering sudo systemctl disable <service_name>, you may also use the condensed version of the systemctl disable command. Every service that is set to launch at system startup can be disabled with this command.

sudo systemctl disable apache2.service
Here is a practical example of systemctl command:

5. How to check service dependency using systemctl command?

These steps may be used to use the systemctl command to verify a service’s dependencies:

On your Linux computer, launch a terminal.
To verify the dependencies of a service, type systemctl list-dependencies followed by the service’s name. For instance, you might execute systemctl list-requirements apache2.service to examine the dependencies of the Apache web server.
Enter is required to carry out the command. The terminal will show a list of all the services, including those on which the specified service depends and those on which it depends.
As an alternative, you may enter systemctl list-dependencies <service_name> to use the abbreviated version of the command. The dependencies of any service that is set up to operate on your system may be verified with this command.

sudo systemctl list-dependencies apache2.service
Here is a practical example of systemctl command:

6. How to reload any service configuration file using systemctl command?

With the systemctl command, you may reload a service configuration file by doing the following:

On your Linux machine, launch a terminal.
To reload the configuration file of a service, use sudo systemctl reload followed by the service’s name. You might execute sudo systemctl reload apache2.service, for instance, to reload the Apache web server’s configuration file.
To carry out the instruction hit Enter. Without pausing or resuming the service, this will refresh the configuration file for the service.
Instead, you may use sudo systemctl reload service name> to use the command’s abbreviated form. Every service that is set up to operate on your system can have its configuration file loaded again using this command.

sudo systemctl reload apache2.service
Here is a practical example of systemctl command:

Conclusion

For managing services on Linux systems, the systemctl command is a significant tool. It gives users access to services’ dependencies, log output, and status information as well as the ability to start, stop, restart, enable, deactivate, and check the status of services. In order to manage a variety of Linux system services, including web servers, databases, and network services, one must use the flexible systemctl command. It gives system administrators who need to administer and troubleshoot Linux servers a standard interface for doing so across various Linux distributions, you can also check the man page of the systemctl command.

That’s all! Thank you for getting this far. I hope you find this article useful. If you did find this article valuable.

Toss us a follow for more amazing articles on Linux, Networking etc

And be sure to share with other Linux folks who you think it might be useful to them.

LEAVE A REPLY

Please enter your comment!
Please enter your name here