How to manage RHEL / CentOS / OEL Linux Services

Redhat enterprise Linux comes with two nice commands

ntsysv – simple TUI (text based interface) interface for configuring runlevels.

chkconfig – chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.

Turn on sshd service on boot

Code:
chkconfig sshd on

Turn on MySQL service on boot

Code:
chkconfig mysqld on

Turn on Apache / httpd service on boot

Code:
chkconfig httpd on

Turn OFF Apache / httpd service on boot

Code:
chkconfig httpd off

List if service is on of off on boot
Use –list option which lists all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel:

Code:
/sbin/chkconfig --list

Sample O/p of above command

Code:
ipmi            0:off   1:off   2:off   3:off   4:off   5:off   6:off
rawdevices      0:off   1:off   2:off   3:on    4:on    5:on    6:off
NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
rpcidmapd       0:off   1:off   2:off   3:off   4:on    5:on    6:off
ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
readahead       0:off   1:off   2:off   3:off   4:off   5:on    6:off
cpuspeed        0:off   1:on    2:on    3:off   4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:off   4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:off   4:on    5:on    6:off
cups            0:off   1:off   2:on    3:off   4:on    5:on    6:off
lm_sensors      0:off   1:off   2:on    3:on    4:on    5:on    6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:off   4:on    5:on    6:off
saslauthd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
apf             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
rhnsd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
snmptrapd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
netplugd        0:off   1:off   2:off   3:off   4:off   5:off   6:off
portmap         0:off   1:off   2:off   3:off   4:on    5:on    6:off
isdn            0:off   1:off   2:on    3:off   4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
ypbind          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
iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
bluetooth       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sysstat         0:off   1:on    2:on    3:on    4:on    5:on    6:off
diskdump        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
dovecot         0:off   1:off   2:on    3:on    4:on    5:on    6:off
named           0:off   1:off   2:off   3:off   4:off   5:off   6:off
nfs             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:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
vsftpd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
openibd         0:off   1:off   2:on    3:off   4:on    5:on    6:off
irda            0:off   1:off   2:off   3:off   4:off   5:off   6:off
monit           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
readahead_early 0:off   1:off   2:off   3:off   4:off   5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
squid           0:off   1:off   2:off   3:off   4:off   5:off   6:off
vmware          0:off   1:off   2:on    3:on    4:off   5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
netdump         0:off   1:off   2:off   3:off   4:off   5:off   6:off
irqbalance      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
snmpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
arptables_jf    0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfslock         0:off   1:off   2:off   3:off   4:on    5:on    6:off
dc_server       0:off   1:off   2:off   3:off   4:off   5:off   6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
psacct          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
tux             0:off   1:off   2:off   3:off   4:off   5:off   6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
spamassassin    0:off   1:off   2:on    3:on    4:on    5:on    6:off
pcmcia          0:off   1:off   2:on    3:off   4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:off   4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
xinetd based services:
        cups-lpd:       off
        finger: off
        eklogin:        off
        klogin: off
        chargen:        off
        daytime-udp:    off
        krb5-telnet:    off
        time-udp:       off
        daytime:        off
        time:   off
        gssftp: off
        kshell: off
        echo-udp:       off
        rsync:  off
        tftp:   off
        vmware-authd:   on
        chargen-udp:    off
        echo:   off

Type ntsysv for GUI tool

Code:
ntsysv

Type serviceconf – GUI tools need X GUI system

Code:
serviceconf

How to see the process threads / lwpid on HP-UX

# pstack <process id>  

# pstack 7604

 

——————————–  lwpid : 7463580   ——————————-

0: 60000000c0379e50 : __ksleep() + 0x30 (/usr/lib/hpux32/libc.so.1)
1: 60000000c013aa10 : __mxn_sleep() + 0xaf0 (/usr/lib/hpux32/libpthread.so.1)
2: 60000000c00d1f50 : pthread_cond_wait() + 0xdd0 (/usr/lib/hpux32/libpthread.so.1)
3: 60000000c00d1210 : pthread_cond_wait() + 0x90 (/usr/lib/hpux32/libpthread.so.1)
4: 60000000c9d4ba20 : _ZN2os4Hpux5Event4downEv() + 0x100 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
5: 60000000c9d4f650 : _ZN13ObjectMonitor4waitExbP6Thread() + 0x1280 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
6: 60000000c9f02550 : _ZN18ObjectSynchronizer4waitE6HandlexP6Thread() + 0xb0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
7: 60000000c9b8ee40 : JVM_MonitorWait() + 0x230 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
8: 2000000073400940 : (unknown) () (unknown)

——————————–  lwpid : 7476079   ——————————-

0: 60000000c0379e50 : __ksleep() + 0x30 (/usr/lib/hpux32/libc.so.1)
1: 60000000c013aa10 : __mxn_sleep() + 0xaf0 (/usr/lib/hpux32/libpthread.so.1)
2: 60000000c00d1f50 : pthread_cond_wait() + 0xdd0 (/usr/lib/hpux32/libpthread.so.1)
3: 60000000c00d43f0 : pthread_cond_timedwait() + 0x130 (/usr/lib/hpux32/libpthread.so.1)
4: 60000000c9d4fd80 : _ZN2os4Hpux5Event4downEx() + 0x2f0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
5: 60000000c9d4ec80 : _ZN13ObjectMonitor4waitExbP6Thread() + 0x8b0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
6: 60000000c9f02550 : _ZN18ObjectSynchronizer4waitE6HandlexP6Thread() + 0xb0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
7: 60000000c9b8ee40 : JVM_MonitorWait() + 0x230 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
8: 2000000073400940 : (unknown) () (unknown)

——————————–  lwpid : 7476080   ——————————-

0: 60000000c0379e50 : __ksleep() + 0x30 (/usr/lib/hpux32/libc.so.1)
1: 60000000c013aa10 : __mxn_sleep() + 0xaf0 (/usr/lib/hpux32/libpthread.so.1)
2: 60000000c00d1f50 : pthread_cond_wait() + 0xdd0 (/usr/lib/hpux32/libpthread.so.1)
3: 60000000c00d43f0 : pthread_cond_timedwait() + 0x130 (/usr/lib/hpux32/libpthread.so.1)
4: 60000000c9d4fd80 : _ZN2os4Hpux5Event4downEx() + 0x2f0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
5: 60000000c9d4ec80 : _ZN13ObjectMonitor4waitExbP6Thread() + 0x8b0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
6: 60000000c9f02550 : _ZN18ObjectSynchronizer4waitE6HandlexP6Thread() + 0xb0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
7: 60000000c9b8ee40 : JVM_MonitorWait() + 0x230 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
8: 2000000073400940 : (unknown) () (unknown)

——————————–  lwpid : 7476082   ——————————-

0: 60000000c0379e50 : __ksleep() + 0x30 (/usr/lib/hpux32/libc.so.1)
1: 60000000c013aa10 : __mxn_sleep() + 0xaf0 (/usr/lib/hpux32/libpthread.so.1)
2: 60000000c00d1f50 : pthread_cond_wait() + 0xdd0 (/usr/lib/hpux32/libpthread.so.1)
3: 60000000c00d43f0 : pthread_cond_timedwait() + 0x130 (/usr/lib/hpux32/libpthread.so.1)
4: 60000000c9d4fd80 : _ZN2os4Hpux5Event4downEx() + 0x2f0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
5: 60000000c9d4ec80 : _ZN13ObjectMonitor4waitExbP6Thread() + 0x8b0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
6: 60000000c9f02550 : _ZN18ObjectSynchronizer4waitE6HandlexP6Thread() + 0xb0 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
7: 60000000c9b8ee40 : JVM_MonitorWait() + 0x230 (/gmac01/oraas/mid/jdk/jre/lib/IA64N/server/libjvm.so)
8: 2000000073400940 : (unknown) () (unknown)

# pstack 7604 |wc -l
331
#