How To: Activate or Deactivate a Service on Linux

Linux, Tips n Tricks, Windows

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

Comments on this entry are closed.

  • luz Jun 15, 2008 Link

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

  • Rohit Jul 6, 2008 Link

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

  • saheer Oct 24, 2008 Link

    PS How can I get that little cloud before the comment link on the blog? Is that Haloscan and Blog template?

  • Tom Dec 5, 2008 Link

    interesting site it really learns me a lot.

  • Yaro Jul 4, 2009 Link

    It’s simpler with Arch Linux. It’s all right there in /etc/rc.conf in one line… the daemons array. I’ll show you mine:

    DAEMONS=(preload syslog-ng network @crond @alsa @hal @fam @sshd @openntpd @samba @gpm @arch32 @bluetooth)

    I can change this with any text editor so long as I use root permissions. The @ on most of them means “launch it in the background.” Means that my init scripts won’t wait until they finish to move on. Drastically improves boot time. Contrariwise, I could instead append a ! on it, which means “do NOT load this daemon.”

    From what I’ve seen with Ubuntu, it has a simpler GUI for handling services, but I prefer Arch. Arch is way more lean than Ubuntu.

  • Nethaji Reddy Puthalapattu Mar 3, 2010 Link

    Really Thank full, Because the one i am searching I got.

  • Engagement Rings Nov 29, 2019 Link

    I am in fact thankful to the holder of this website who has shared this fantastic paragraph
    at here.