By now, if you’ve played around with CentOS 7 (or RHEL 7), you’ve heard that there are now systemd commands you can start using to start, restart and stop various services. They still have the ‘service’ command included for backwards compatibility, but that may go away in future releases. Here’s a little tutorial to help you learn the systemd commands!
Ok, so you’re on your new CentOS 7 (or RHEL 7) system (we’ll just call it CentOS 7 for now to make it easier) and you restarted sshd with the old/familiar ‘service sshd restart’ command and you’re met with this: Redirecting to /bin/systemctl restart sshd.service
1 2 |
[root@centos7 ~]# service sshd restart Redirecting to /bin/systemctl restart sshd.service |
Now, it still restarted it, but that little note is annoying. It’s basically telling you “hey – things have changed… use systemctl now!”
You could now type ‘systemctl restart sshd’ for a shorter version.. here are some examples:
Stop service:
1 |
systemctl stop httpd |
Start service:
1 |
systemctl start httpd |
Restart service (stops/starts):
1 |
systemctl restart httpd |
Reload service (reloads config file):
1 |
systemctl reload httpd |
List status of service:
1 |
systemctl status httpd |
What about chkconfig? That changed too? Yes, now you want to use systemctl for the chkconfig commands also..
chkconfig service on:
1 |
systemctl enable httpd |
chkconfig service off:
1 |
systemctl disable httpd |
chkconfig service (is it set up to start?)
1 |
systemctl is-enabled httpd |
chkconfig –list (shows what is and isn’t enabled)
1 |
systemctl list-unit-files --type=service |