AMP AMP

How to Manage Services with update-rc.d on Ubuntu 21.04

To Manage Services with update-rc.d on Ubuntu 21.04

Introduction:

Update-rc.d updates the System V data-style init script links which updates the System V data-style init script. Init runs these links when changing run levels. In general, they are used to start and stop system services such as daemons.

Installation Procedure:

Step 1: Check the OS version by using the below command

root@linuxhelp:~# lsb_release -a 
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 2: Check the Activity status of the services by using the below command

root@linuxhelp:~# systemctl is-active apache2 && systemctl is-active mariadb 
active
active

Step 3: Remove all the starting scripts on apache2 service by using the below command

root@linuxhelp:~# update-rc.d -f apache2 remove

Step 4: Remove all the starting scripts on mariadb services by using the below command

root@linuxhelp:~# update-rc.d -f mariadb remove 

Step 5: Stop the services by using the below command

root@linuxhelp:~# service apache2 stop && service mariadb stop 

Step 6: Recheck the Activity status of the services by using the below command

root@linuxhelp:~# systemctl is-active apache2 && systemctl is-active mariadb 
inactive

Step 7: Enable the apache2 service as defaults by using the below command

root@linuxhelp:~# update-rc.d apache2 defaults 

Step 8: Enable the mariadb service as defaults

root@linuxhelp:~# update-rc.d mariadb defaults 

Step 9: Start and kill the apache2 service with custom priorities

root@linuxhelp:~# update-rc.d apache2 defaults 90 90

Step 10: Start and kill the mariadb service with custom priorities

root@linuxhelp:~# update-rc.d mariadb defaults 10 10

Step 11: Enable the apache2 service with custom run levels

root@linuxhelp:~# update-rc.d apache2 enable 2 3 4 5

Step 12: Enable the mariadb service with custom run levels

root@linuxhelp:~# update-rc.d mariadb enable 2 3 4 5

Step 13: Start the apache2 service by using the below command

root@linuxhelp:~# service apache2 start 

Step 14: Start the mariadb service by using the below command

root@linuxhelp:~# service mariadb start 

By this to Manage Services with update-rc.d on Ubuntu 21.04 have been completed.

FAQ
Q
How to set Start and Kill priority for services?
A
To set Start and Kill priority for services use command
Q
How to view all services in the system?
A
To view all services in the system use command
Q
What does that the -f do in update-rc.d?
A
The option -f will Force the removal of symlinks even if /etc/init.d/name still exists.
Q
What mean command?
A
This command means that the init.d script will be disabled for the named service.
Q
What are the service managing commands for Debian and Ubuntu systems?
A
Service commands are used by Debian and Ubuntu to manage services and update-rc.d is used to add and remove services from the startup menu.