Recommended VPS Complete list of best VPS hosting providers.

Meet SystemCtl on CentOS 7

Why should I use systemctl on my vps running CentOS 7? What is systemctl command and how to use it?

Such a nice question! The newly made available on CentOS 7, systemctl is a command to control system daemons. This command is available on recent (modern) distros including Fedora 18 or above, RHEL 7, and of course CentOS 7.  This systemctl command is available because the Developers behind CentOS 7 replaced upstart with systemd as the default init system. It means now systemd becomes default system management daemon which is different from the old default init system in many aspects that is too long to explain here.

So how to use it? If you are used to the old init scripts, then the new syntax can be slightly confusing. For example:

Old init scripts to restart httpd:

/etc/init.d/httpd restart

or,..

service httpd restart

then the new command will be:

systemctl restart httpd.service

You can also start and stop the service with similar syntax:

systemctl start httpd.service
systemctl stop httpd.service

p.s:You’ll need to login as root or as a user with root privilege and prepend sudo in front of the commands to use sudo instead of directly accessing the root account. For example:

systemctl restart nginx.service

Why should I use systemctl? For your information, you can still use old init script like examples above but you better start using systemctl and get used to it. The service, /etc/init.d/ and chkconfig commands are still available in the system and work as expected, but are only included for backward compatibility and legacy support reasons. But however if you get used to systemctl, you won’t get confused if the old commands be removed in future updates or releases.

Common command syntax:

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

for example:

systemctl reload sshd.service

That’s it. Do not forget to follow me on twitter or download my official Android app.

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.