Configuring services in Linux

This entry was posted in Linux and tagged on June 17, 2012, by

What are services?

Services are the program which onces started run in the background. For example suppose apache server has daemons httpd which listen’s to port 80 and when it receives request its send appropriate request back to client.

Following are the commands which is use to start and stop the services and also control the services to bring it automatically at boot time.

*chkconfig : It will control which services to start and stop  at boot time

*service: It will control the start and stop of the service.

Find the services in Redhat which starts at boot

# chkconfig –list

NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
NetworkManagerDispatcher        0:off   1:off   2:off   3:off   4:off   5:off  6:off
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off

apmd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-dnsconfd  0:off   1:off   2:off   3:off   4:off   5:off   6:off
bluetooth       0:off   1:off   2:on    3:on    4:on    5:on    6:off
capi            0:off   1:off   2:off   3:off   4:off   5:off   6:off
conman          0:off   1:off   2:off   3:off   4:off   5:off   6:off
cpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
cups            0:off   1:off   2:on    3:on    4:on    5:on    6:off
dc_client       0:off   1:off   2:off   3:off   4:off   5:off   6:off
dc_server       0:off   1:off   2:off   3:off   4:off   5:off   6:off

dhcdbd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
dund            0:off   1:off   2:off   3:off   4:off   5:off   6:off
firstboot       0:off   1:off   2:off   3:on    4:off   5:on    6:off
gpm             0:off   1:off   2:on    3:on    4:on    5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off
hidd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
hplip           0:off   1:off   2:on    3:on    4:on    5:on    6:off
httpd           0:off   1:off   2:off   3:off   4:off   5:on    6:off
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
ipmi            0:off   1:off   2:off   3:off   4:off   5:off   6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
irda            0:off   1:off   2:off   3:off   4:off   5:off   6:off
irqbalance      0:off   1:off   2:on    3:on    4:on    5:on    6:off
isdn            0:off   1:off   2:on    3:on    4:on    5:on    6:off
jexec           0:on    1:on    2:on    3:on    4:on    5:on    6:on
kdump           0:off   1:off   2:off   3:off   4:off   5:off   6:off

kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
mcstrans        0:off   1:off   2:on    3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
mdmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
multipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
mysqld          0:off   1:off   2:off   3:on    4:off   5:on    6:off
nagios          0:off   1:off   2:on    3:on    4:on    5:on    6:off
named           0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
netplugd        0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfslock         0:off   1:off   2:on    3:on    4:on    5:on    6:off
nscd            0:off   1:off   2:off   3:off   4:off   5:off   6:off
ntpd            0:off   1:off   2:off   3:off   4:off   5:off   6:off
openibd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
pand            0:off   1:off   2:off   3:off   4:off   5:off   6:off
pcscd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:on    3:on    4:on    5:on    6:off
psacct          0:off   1:off   2:off   3:off   4:off   5:off   6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
readahead_early 0:off   1:off   2:on    3:on    4:on    5:on    6:off
readahead_later 0:off   1:off   2:off   3:off   4:off   5:on    6:off
restorecond     0:off   1:off   2:on    3:on    4:on    5:on    6:off
rhnsd           0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcsvcgssd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
setroubleshoot  0:off   1:off   2:off   3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
smb             0:off   1:off   2:off   3:off   4:off   5:off   6:off
squid           0:off   1:off   2:off   3:off   4:off   5:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
tux             0:off   1:off   2:off   3:off   4:off   5:off   6:off
vncserver       0:off   1:off   2:off   3:on    4:off   5:on    6:off
vsftpd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
wdaemon         0:off   1:off   2:off   3:off   4:off   5:off   6:off
winbind         0:off   1:off   2:off   3:off   4:off   5:off   6:off
wpa_supplicant  0:off   1:off   2:off   3:off   4:off   5:off   6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
xinetd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
ypbind          0:off   1:off   2:on    3:on    4:on    5:on    6:off
yppasswdd       0:off   1:off   2:on    3:on    4:on    5:on    6:off
ypserv          0:off   1:off   2:on    3:on    4:on    5:on    6:off
ypxfrd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
yum-updatesd    0:off   1:off   2:on    3:on    4:on    5:on    6:off

This command will list all the services in redhat . It will display on which which run level the given services is on and which is off.

Various Run levels.

Level            Descriptions

0                  System halts on this run level

1                  This is single user mode

2                  Multiuser Mode

3                  Full multiuser without X

4                  Not in used

5                  Multi user mode with X

6                  Reboot

Now consider the example to look for given services. Suppose we want to see on what run level ssh is working. Run the follwoing command

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

You will see its runing on 2, 3 and 5

This will bring the service on boot time. Suppose we dont want to bring it on boot time, run the following command

# chkconfig –level 5 sshd off

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

You will see its will not start up at boot.

Now the other command to start and stop services is “service” command

To start a service simply used “service <service-name> start ” to stop a service simply use ” service <service-name> stop”

To stop given service:

# service sshd stop
Stopping sshd:                                             [  OK  ]

To start given service:

# service sshd start
Starting sshd:                                             [  OK  ]

Also we can use service command to grep all the services which are running.

# service –status-all| grep running
acpid (pid 3355) is running…
atd (pid 3692) is running…
auditd (pid 3280) is running…
automount (pid 3335) is running…
Avahi daemon is running
Avahi DNS daemon is not running
hcid (pid 3188) is running…
sdpd (pid 3194) is running…
capi not installed – No such file or directory (2)
crond (pid 3579) is running…
cupsd (pid 3397) is running…
gpm (pid 3556) is running…
hald (pid 3762) is running…
hidd (pid 3304) is running…
hpiod (pid 3366) is running…
hpssd (pid 3371) is running…
httpd (pid 12412 12411 12410 12409 12408 12407 12406 12405 3568) is running…
irqbalance (pid 3048) is running…
mcstransd (pid 3064) is running…
dbus-daemon (pid 4754 3176) is running…
mysqld (pid 3500) is running…
nagios (pid 4010) is running…
rndc: connect failed: 127.0.0.1#953: connection refused
rpc.mountd (pid 27163) is running…
nfsd (pid 27160 27159 27158 27157 27156 27155 27154 27153) is running…
rpc.statd (pid 3118) is running…
pcscd (pid 3263) is running…
portmap (pid 3097) is running…
restorecond (pid 3022) is running…
rpc.idmapd (pid 3157) is running…
sendmail (pid 3544 3535) is running…
setroubleshootd (pid 3317) is running…
smartd (pid 4027) is running…
squid: ERROR: No running copy
sshd (pid 4176 3898) is running…
syslogd (pid 3033) is running…
klogd (pid 3036) is running…
Xvnc (pid 25313) is running…
xfs (pid 3618) is running…
xinetd (pid 3409) is running…
ypbind (pid 27992) is running…
rpc.yppasswdd (pid 27746) is running…
ypserv (pid 27765) is running…
rpc.ypxfrd (pid 28021) is running…
yum-updatesd (pid 3964) is running…

 

You will see it will display all services which is running.

Leave a Reply

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

Copyright 2017 ©Aceadmins. All rights reserved.