How to Setup and Use Systemctl on Centos (with Pictures)
Edit Article

  • 1 Editor

Like most of the people who are running CentOS, you must have a few questions. Like what are the benefits that would make me want to use systemctl on my VPS running CentOS7. Also about what actually systemctl command is and how are we supposed to use it. All your questions shall be answered in this article as they are all excellent questions.


Systemctl is a new command that has been introduced and made available on CentOS 7. This command is used to control all the system daemons. The systemctl command is available on all the recent and modern distros. These include the Fedora 18 or above, RHEL 7 and of course our favorite the CentOS 7. Because the developers of the CentOS replaced the upstart with systemd as the default init system so they made sure that systemctl command was made available. This can mean only one thing; systemd is from now on the default system management daemon. Systemd differs from the old default init system in a lot of different ways. I will not be explaining all those as they are too long to explain here.


Now is the question of how to actually use this. The new syntax given by the developers of CentOS is a bit confusing if you are used to the old init scripts. For example:


There was this old init script that was used to restart httpd:

1

Or alternatively:

2

But now, the new command will be:

3

Whereas this similar syntax can also be used to start and stop the service:

4
5

Just so you know, you will need to log in as root or in not as root then as a user who has root privileges. Now you can prepend sudo in front of the commands. This will help use sudo instead of accessing the root account directly. Here is an example:

6

You must be asking that what the need to use systemctl is. This should be mentioned that there is no compulsion whether you use the old init script like the examples that are given above or the new systemctl syntax. But it is better if you start using the new syntax and get used to it quickly. The system still gives you the service, /etc/inint.d/ and chkconfig commands. All of these are still available with the old syntax are work as they are supposed to. These commands are there for legacy support and backward compatibility. Getting to use to systemctl is a necessity because then you won’t be confused if the developers someday remove the old commands somewhere in the future updates.


The command syntax that is commonly used:


systemctl start|stop|restart|reload|status servicename.service


For Example:

7

That is it. You now know what systemctl is and what are the benefits of using systemctl.

Article Tools

Did this article help you?

YesNo

Become
an Author!

Write an Article