How To: Activate or Deactivate a Service on Linux

by venukb on June 13, 2008

A service is a long running executable which does require any user intervention and is configured to start when the operating system is booted.

On Windows, the services are managed via services.msc and you can also communicate with a NT service using the SC tool.

On Linux the services can be controlled via the chkconfig command line tool.

Usage details of chkconfig  is shown below:

chkconfig –list [name]
chkconfig –add <name>
chkconfig –del <name>
chkconfig [--level <levels>] <name> <on|off|reset>

Add and Del options are used to create or delete services for management. A service can be activated or deactivated using the on or off flags. Note that you have to mention the runlevel using the --level option.

The absensce of this runlevel will lead to the settings being applied to the current runlevel.

The <name> argument refers to the name of the service and this can be found by referring to the /etc/init.d director on Linux, which is a central repository for all startup scripts.

Also note that chkconfig modifies the data on /etc/rc[0-6].d directories and not the actual startup scripts.

A much faster way of enabling or disabling Linux services is by using the ntsysv command.

The command lists the services available on the repository (/etc/init.d) and enables the user to disable/enable services in one shot.

Also if the service name looks too cryptic, you can always press F1 to get more information about the selected service.

As with chkconfig, if you need to control the services at multiple runlevel’s you need to invoke ntsysv with the --level argument

ntsysv –level 345 will configure the services on runlevel 3, 4 and 5.

If you are a Linux newbie, Linux.com has an excellent introduction to Services, runlevel’s and rc.d scripts.

Note: In Debian, services are managed using the update-rc.d command

Popularity: 2% [?]

{ 2 comments… read them below or add one }

1 luz 06.15.08 at 8:00 am

Im not so much into computer programming stuff but anyway thanks for the info.

2 Rohit 07.06.08 at 3:12 am

Keep on blogging, we need you. I’ve got so much useful stuff from your blog and really value you opinion in this stuff.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>