Manage Linux init or startup scripts

Init scripts are small shell programs that usually control services, also known as daemons. Other applications for init scripts involve simply controlling the state of something such as hdparm (HDD sleep timeouts), iptables (loading firewall rule-sets into the kernel) and setserial (COM port configuration).The /etc/init.d directory contains the scripts executed by init at boot time and when the init state.

Init scripts are also important during startup and shutdown (simply “runlevel” changes on *nix systems). If you take a look at the list of processes running on your machine (try ps auwx), chances are that the process with the lowest PID is called “init”. This is the parent of all processes; it’s the first program the kernel starts when booting. init , which can be found in /sbin/init, is responsible for getting the system up and running after the kernel has finished booting.

There are three simple utilities to manage your startup or init scripts




Now we will see one by one with some examples


Rcconf allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot. The ones that are configured to do so are marked and you can toggle individual services on and off.This tool configures system services in connection with system runlevels. It turns on/off services using the scripts in /etc/init.d/. Rcconf works with System-V style runlevel configuration. It is a TUI(Text User Interface) frontend to the update-rc.d command.

Rcconf gets a list of services from /etc/init.d and looks in the /etc/rc?.d directories to determine whether each service is on or off.

If the number(NN of /etc/rc?.d/NNname) is not 20(default), rcconf saves the service name and the number in /var/lib/rcconf/services so as to be able to restore the service to its original configuration.

Install rcconf in debian

#apt-get install rcconf

This will complete the installation now if you want to run this application use the following command


you should see the following screen here you can select which services you want to run at boot time

Important Files

/var/lib/rcconf/services - The service number data file.

/var/lib/rcconf/lock - Lock file.

/var/lib/rcconf/guide.default - Guide File update-rcconf-guide generates.

/var/lib/rcconf/guide - Guide File user(Administrator) can define.

If you want to know more about rcconf check man page


install and remove System-V style init script links.update-rc.d automatically updates the System V style init script links /etc/rcrunlevel.d/NNname to scripts /etc/init.d/name. These are run by init when changing runlevels and are generally used to start and stop system services such as daemons. runlevel is one of the runlevels supported by init, 0123456789S, and NN is the two-digit sequence code used by init to decide which order to run the scripts in.

update-rc.d Syntax

update-rc.d [-n] [-f] name remove

update-rc.d [-n] name defaults [NN | NN-start NN-stop]

update-rc.d [-n] name start|stop NN runlevel runlevel start|stop NN runlevel runlevel

When run with either the defaults, start, or stop options, update-rc.d makes links /etc/rcrunlevel.d/[SK]NNname pointing to the script /etc/init.d/name,If any files /etc/rcrunlevel.d/[SK]??name already exist then update-rc.d does nothing. This is so that the system administrator can rearrange the links, provided that they leave at least one link remaining, without having their configuration overwritten.

Available Options

-n Don’t do anything, just show what we would do.

-f Force removal of symlinks even if /etc/init.d/name still exists.

update-rc.d Examples

Insert links using the defaults

#update-rc.d samba defaults

Equivalent command using explicit argument sets

#update-rc.d samba start 20 2 3 4 5 . stop 20 0 1 6 .

If you want to remove the script from the startup use the following command

# update-rc.d -f samba remove

If you want to know more about update-rc.d check man page


Alternative boot mechanism using a single configuration file This package provides an alternative mechanism to boot the system, to shut it down and to change runlevels. The /etc/rc?.d/* links will be converted into one single configuration file /etc/runlevel.conf instead, which is easier to administrate than symlinks, and is also more flexible. The package will automatically convert your existing symlinks into the file method on installation, and convert the file back into symlinks on removal. Both mechanisms are compatible through /etc/init.d/rc, /etc/ init.d/rcS, /usr/sbin/update-rc.d, and /usr/sbin/invoke-rc.d scripts.

Install file-rc in debian

# apt-get install file-rc
Reading Package Lists… Done
Building Dependency Tree… Done
The following packages will be REMOVED:
rcconf sysv-rc
The following NEW packages will be installed:
WARNING: The following essential packages will be removed
This should NOT be done unless you know exactly what you are doing!
sysv-rc (due to sysvinit)
0 upgraded, 1 newly installed, 2 to remove and 5 not upgraded.
Need to get 36.3kB of archives.
After unpacking 119kB disk space will be freed.
You are about to do something potentially harmful
To continue type in the phrase ‘Yes, do as I say!’
?]Yes, do as I say!
Get:1 stable/main file-rc 0.8.7 [36.3kB]
Fetched 36.3kB in 0s (231kB/s)
(Reading database … 20533 files and directories currently installed.)
Removing rcconf …
dpkg: sysv-rc: dependency problems, but removing anyway as you request:
sysvinit depends on sysv-rc (>= 2.85-2) | file-rc (>> 0.7.0); however:
Package sysv-rc is to be removed.
Package file-rc is not installed.
Removing sysv-rc …
Selecting previously deselected package file-rc.
(Reading database … 20507 files and directories currently installed.)
Unpacking file-rc (from …/archives/file-rc_0.8.7_all.deb) …
Setting up file-rc (0.8.7) …

Configuration file for file-rc is located at /etc/runlevel.conf.If you want to know the default configuration file check here


05 - 0 /etc/init.d/halt
05 - 1 /etc/init.d/single
05 - 6 /etc/init.d/reboot
10 0,1,6 2,3,4,5 /etc/init.d/sysklogd
12 0,1,6 2,3,4,5 /etc/init.d/kerneld
89 0,1,6 2,3,4,5 /etc/init.d/cron
99 - 2,3,4,5 /etc/init.d/rmnologin
99 0,1,6 2,3,4,5 /etc/init.d/xdm

If you want to know more details about file-rc check man page