Dealing with services in RHEL 7 (Part – 1)

In RHEL 7 systemd replaced Upstart of RHEL 6 as the default init system. In this post I am going to show you the new commands which we will use in RHEL 7 to deal with services. Even old commands like service and chkconfig are still present but redhat recommends to use the systemctl commands only to control the serivces in RHEL 7.

Dealing with Services in RHEL 7 is different from RHEL 6. Now all the services are ending with suffix .service

Now below directory contains the link to services which are supposed to be start during boot of server.

[root@localhost system]# cd /etc/systemd/system/
[root@localhost system]# ll | grep -i service
lrwxrwxrwx. 1 root root 41 May 27 14:48 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx. 1 root root 41 May 27 14:44 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service
lrwxrwxrwx. 1 root root 44 May 27 14:46 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx. 1 root root 44 May 27 14:53 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx. 1 root root 46 May 27 14:47 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root 57 May 27 14:47 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx. 1 root root 35 May 27 14:49 display-manager.service -> /usr/lib/systemd/system/gdm.service
lrwxrwxrwx. 1 root root 39 May 27 14:43 syslog.service -> /usr/lib/systemd/system/rsyslog.service

1) How to check the currently loaded services or I can say active services?

[root@localhost system]# systemctl list-units –type service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrt-xorg.service loaded active running ABRT Xorg log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting Tool
alsa-state.service loaded active running Manage Sound Card State (restore and store)

2) How to list all installed units to determine whether they are active or not ?

[root@localhost system]# systemctl list-unit-files –type service
UNIT FILE STATE
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-pstoreoops.service disabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled

3) How to check the status of individual service?

[root@localhost system]# systemctl status abrtd
abrtd.service – ABRT Automated Bug Reporting Tool
Loaded: loaded (/usr/lib/systemd/system/abrtd.service; enabled)
Active: active (running) since Tue 2014-06-03 16:18:48 IST; 2h 38min ago
Main PID: 860 (abrtd)
CGroup: /system.slice/abrtd.service
ââ860 /usr/sbin/abrtd -d -s

Jun 03 16:18:48 localhost.localdomain systemd[1]: Started ABRT Automated Bug Reporting Tool.
Jun 03 16:18:52 localhost.localdomain abrtd[860]: Searching for unprocessed dump directories
Jun 03 16:18:52 localhost.localdomain abrtd[860]: Init complete, entering main loop

It is much more elaborative than previous service status command of RHEL 6.

4) How to check whether service is configured to run after reboot?

[root@localhost system]# systemctl is-enabled abrtd
systemctl is-enabled abrtd
enabled

Similarly other commands will be:

systemctl enable abrtd Enables the service to start at boot time. Will create symbolic link in /etc/systemd/system.
systemctl disable abrtd Disables the service to start at boot time. Will remove the symbolic link in /etc/systemd/system.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s