Dealing with service in RHEL 7 ( Part – 2 )

How to mask the service ? What is the need of it ?

Suppose on server you want the service to mask you can issue the below command to mask that service. Now coming to need of it if you want a service neither to started automatically nor manually then we mask it. As soon as we mask that service It will created symbolic link of that service to /dev/null file in /etc/systemd/system location. Status command later on confirmed that service is masked.

[root@localhost system]# systemctl mask bluetooth
ln -s ‘/dev/null’ ‘/etc/systemd/system/bluetooth.service’

[root@localhost system]# ll | grep -i bluetooth
lrwxrwxrwx. 1 root root 9 Jun 3 19:01 bluetooth.service -> /dev/null
drwxr-xr-x. 2 root root 30 May 27 14:48 bluetooth.target.wants
lrwxrwxrwx. 1 root root 41 May 27 14:48 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service

[root@localhost system]# systemctl status bluetooth
bluetooth.service
Loaded: masked (/dev/null)
Active: inactive (dead)

Jun 03 16:33:57 localhost.localdomain bluetoothd[3254]: bluetoothd[3254]: Bluetooth Management interface initialized
Jun 03 16:33:57 localhost.localdomain bluetoothd[3254]: Bluetooth Management interface initialized
Jun 03 18:45:34 localhost.localdomain systemd[1]: Stopping Bluetooth service…
Jun 03 18:45:34 localhost.localdomain bluetoothd[3254]: bluetoothd[3254]: Terminating
Jun 03 18:45:34 localhost.localdomain bluetoothd[3254]: Terminating
Jun 03 18:45:36 localhost.localdomain bluetoothd[3254]: bluetoothd[3254]: Stopping SDP server
Jun 03 18:45:36 localhost.localdomain bluetoothd[3254]: Stopping SDP server
Jun 03 18:45:36 localhost.localdomain bluetoothd[3254]: bluetoothd[3254]: Exit
Jun 03 18:45:36 localhost.localdomain bluetoothd[3254]: Exit
Jun 03 18:45:43 localhost.localdomain systemd[1]: Stopped Bluetooth service.

Later on you decided that you want that service nothing to worry simple reverse the action by unmasking that service. It will simple remove the link to /dev/null.

[root@localhost system]# systemctl unmask bluetooth
rm ‘/etc/systemd/system/bluetooth.service’

[root@localhost system]# ll | grep -i bluetooth
drwxr-xr-x. 2 root root 30 May 27 14:48 bluetooth.target.wants
lrwxrwxrwx. 1 root root 41 May 27 14:48 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service

Will post more articles on services in RHEL 7

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