Search This Blog

Monday, January 4, 2016

RHEL6 - Controlling Services and Daemons

Daemons are process that wait or run in the backgroup performing various tasks. Generally daemons start automatically at boot time and continue to run until shutdown or they are manually stopped. By Convention, the names of many daemon programs end in the letter "d"

Daemons are managed by service scritps, which are kept in the /etc/rc.d/init.d/ directory. Service scripts are usually called with single start, stop, restart, status, or reload argument. The easiest way to run service scripts is to use the service command.

Services are enabled (configured to start automatically at boot time) with chkconfig service on. Services are disabled (configured not to start automatically at boot time) with chkconfig service off.

Without argument, chkconfig list the current configuration of all services. The runlevels in which a service is enabled can be observed with chkconfig --list service. Running the chkconfig command does not immediately affect the state of a daemon started from a service script.

Daemons are managed by service scritps, which are kept in the /etc/rc.d/init.d/ directory
# /etc/rc.d/init.d/sshd                [start/stop/status]


Starting the ssh service:
[root@server1 /]# service sshd start
Starting sshd:                                             [  OK  ]

Stooping the ssh service:
[root@server1 /]# service sshd stop
Stopping sshd:                                             [  OK  ]

Checking the service status:
[root@server1 /]# service sshd status
openssh-daemon (pid  3062) is running...

If the daemon is not running, what likely next steps could you take?
a. Examing /var/log/messages or service specific log files.
b. Try to start the daemon "manually from the command line, and look for any complaints

To check the daemon is running, run the following command:
[root@server1 init.d]# ps aux|grep sshd
root      3062  0.0  0.0  66604  1156 ?        Ss   00:16   0:00 /usr/sbin/sshd

To start/stop the process manually
[root@server1 init.d]# pwd
/etc/rc.d/init.d
[root@server1 init.d]# ls -l|grep ssh
-rwxr-xr-x. 1 root root  4534 Sep 30  2013 sshd

[root@server1 init.d]# ./sshd stop
Stopping sshd:                                             [  OK  ]
[root@server1 init.d]# ./sshd start
Starting sshd:                                             [  OK  ]

Check how the service is configured to start at various run level:
[root@server1 init.d]# chkconfig --list sshd
sshd                  0:off  1:off  2:on   3:on   4:on   5:on   6:off

Turn off start of service sshd at run level 2
[root@server1 /]# chkconfig --level 2 sshd off
[root@server1 /]# chkconfig --list sshd
sshd                  0:off  1:off  2:off  3:on   4:on   5:on   6:off

Turn on start of service sshd at run level 2
[root@server1 /]# chkconfig --level 2 sshd on
[root@server1 /]# chkconfig --list sshd
sshd                  0:off  1:off  2:on   3:on   4:on   5:on   6:off

# chkconfig sshd off will off the services at each run level
# chkconfig sshd on will start the services at each run level

[root@server1 /]# chkconfig --list
NetworkManager        0:off  1:off  2:on   3:on   4:on   5:on   6:off
abrt-ccpp             0:off  1:off  2:off  3:on   4:off  5:on   6:off
abrtd                 0:off  1:off  2:off  3:on   4:off  5:on   6:off
acpid                 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
blk-availability      0:off  1:on   2:on   3:on   4:on   5:on   6:off
bluetooth             0:off  1:off  2:off  3:on   4:on   5:on   6:off
certmonger            0:off  1:off  2:off  3:on   4:on   5:on   6:off


Thank you for reading.

For Reading other article, visit to “https://sites.google.com/site/unixwikis/

No comments:

Post a Comment