Contact for queries :


  UpComing Live WebEx Workshop Series

Linux Service Management

On any system it is important to manage the running services. Managing services enables you to ensure the stability and reliability that your system will offer.

A service can range from something simple, such as providing your local system with the correct time, or something more complex, such as sharing a file system over the entire network for your users using NFS.

Knowing how to manage services is a big part of the Red Hat exams (as defined by the Red Hat Prep Guide), but it is also a critical system administrator skill in the real world.

In Linux, services can also be called daemons. The reason for this is that some services are actually composed of multiple daemons. One example of this is NFS.

You can usually tell if something is a daemon because it (the service name) ends in a d.

An example of this would be the SSH service (sshd) or the Apache web service (httpd).

Let’s look again at the different runlevels and how they deal with services during the boot process. Because the preceding section ended by moving the system into runlevel 3, why don’t we start by looking in the /etc/rc.d/rc3.d directory (which correlates to runlevel 3):

# ls /etc/rc.d/rc3.d/
K01dnsmasq K50ibmasm K89pand S08iptables
K02avahi-dnsconfd K50netconsole K89rdisc S08mcstrans
K02NetworkManager K69rpcsvcgssd K91capi S09isdn
K02oddjobd K73ypbind K99readahead_later S10network
K05conman K74nscd S00microcode_ctl S11auditd
K05saslauthd K85mdmpd S02lvm2-monitor S12restorecond
K10psacct K87multipathd S04readahead_early S12syslog
K10tcsd K88wpa_supplicant S05kudzu S13irqbalance
K20nfs K89dund S06cpuspeed S13portmap
K24irda K89netplugd S08ip6tables S14nfslock

You wouldn’t know by looking at the output of this command, but these are all actually soft links to scripts on the system, usually within the /etc/rc.d/init.d directory.

You can also see from the output that each link has an interesting syntax. The syntax is something like


In Each file name:

  • The K stands for Kill and the S stands for Start.
  • The ## are any number between 01 and 99, including duplicates.
  • Finally, there is the name of the service.

How this thing works?

When you put all this together, you get a listing of every service that is either stopped (K) or started (S) when the system enters runlevel 3.

The numbers indicate the order in which a service is stopped or started, with all Kills being processed first (in numerical order from 1 to 99) and then all Starts being processed second (in numerical order from 1 to 99). If the number order is the same, the alphabetical sort dictates the order.

Now suppose you have the following three services listed in your directory:

■ K15httpd
■ S10network
■ S55sshd

When the system moves to runlevel 3, the first thing to happen would be the system stopping the httpd service (httpd is the Apache Web Server).

Next, the network service would be started, bringing up the network interfaces (this includes assigning the system an IP address). Finally,

the sshd service would be started, providing you with an SSH server for remote management.

This order should make sense because you can’t connect to a server for remote management unless the network interfaces are up with an assigned IP address first!

To ease the management of services at each runlevel, you can use the chkconfig command.

chkconfig [option] service_name
–list [name] Shows the status of the service at each runlevel
–add <name> Adds a service to be managed by the chkconfig command
–del <name> Removes a service from being managed by the chkconfig command
–level <levels> Enables or disables the service at the given levels
<name> <on|off|

Enables or disables the service at levels 2–5

Step 1. Check the status of the sshd service:

# chkconfig –list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

This should be fairly easy to understand. The sshd service will be started at runlevels 2, 3, 4, and 5. It will be stopped at runlevels 0, 1, and 6. 

Now say that you want the sshd service to be completely turned off at all runlevels.

Step 2. Use the off option to disable the service at boot:

# chkconfig sshd off

Step 3. Verify with the original command:

# chkconfig –list sshd
sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Now the sshd service will not start at all when the system boots. Because this is the service used for remote management, this result probably isn’t desirable, so you should probably turn it back on.

Step 4. Re-enable the SSH service:

# chkconfig sshd on

Step 5. Verify again:

# chkconfig –list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

As you can see, it has now been restored. You could also turn off this service for runlevel 4, though, because this runlevel is unused. To edit just one (or multiple) runlevel, you can do this:

# chkconfig –level 4 sshd off

Step 6. You should verify one last time:

# chkconfig –list sshd
sshd 0:off 1:off 2:on 3:on 4:off 5:on 6:off

Second tool to manage Services ntsysv :

Aside from using the chkconfig command, you can accomplish all the same tasks by using the ntsysv command.

The only difference is that ntsysv is menu driven, making it more visually appealing. You can enable and disable different services just as you would with chkconfig.

To manage the different runlevels, you just call the ntsysv command with the runlevel(s) you want to manage.

To edit all services at runlevel 2, just run the command

# ntsysv –level 2

And you will see Textual menu opened on your your screen as shown below


The Next important service manager task that Linux Administrators responsible :

What happens when the system boots and you want to start a service that you forgot to include in the startup services?

Do you have to use the chkconfig command to add it and reboot the system?


We can use  the service command, to start, stop, and query the status of services on the system after it has already booted.

Syntax: service <–status-all | service_name CMD>

How to use Service Command?

Step 1. Usually, it is a good idea to always check the status of the service first:

# service ntpd status
ntpd is stopped

Step 2. When you know that the service is stopped, you can start it:

# service ntpd start
Starting ntpd: [ OK ]

You always see an OK or Fail to indicate whether the service started successfully.
Because this service was off when the system started, you should turn it back off for now.

Step 3. Stop the NTP service:

# service ntpd stop
Shutting down ntpd: [ OK ]

You should make it a habit to verify the status of a service any time you make a change to it.

Step 4. Verify that you stopped the service successfully:

# service ntpd status
ntpd is stopped

Some Important Questions related to Service Management

1. What command can you use to manage system services?
Ans. The service command is used to start, stop, and manage system services.
2. What command disables the SSH service from running when the system boots?
Ans. chkconfig sshd off
3. How can you list all services on the system to tell whether they will boot during startup?
Ans. chkconfig —list
4. What does S12rsyslog in the /etc/rc.d/rc2.d directory mean?
Ans. When the system enters into runlevel 2, the rsyslog service has a priority of 12 when starting. Anything with a lower number (or the same number and lower first letter) starts before the rsyslog service.
5. How can you verify the status of the SSH service after the system has booted?
Ans. service sshd statuts
6. What command and option can you use to enable a service to start on boot?
Ans. Use the chkconfig command to enable or disable services during the boot process. The on option enables the service and off disables it.

November 14, 2015

0 responses on "Linux Service Management"

Leave a Message

Your email address will not be published. Required fields are marked *


IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base for the best practices and Knowledge learning.

copyright protected - 2011 © igurkul I.T. solutions. All rights reserved.