最近发现telnet的服务xinetd名字不好记,应该重命名成telnetd(Linux很多这样的服务vsftpd,ntpd,mysqld等)
 
找到xinetd的启动脚本,复制成telnetd
[root@RHEL6 /etc/init.d]$cp xinetd telnetd
 
加入启动列表
[root@RHEL6 /etc/init.d]$   chkconfig  --add telnetd
加入成功与否
[root@RHEL6 /etc/init.d]$chkconfig --list |grep telnetd
telnetd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
 
测试
[root@RHEL6 /etc/init.d]$service telnetd status
xinetd (pid  3904) is running...
[root@RHEL6 /etc/init.d]$service telnetd stop
Stopping xinetd: [  OK  ]
[root@RHEL6 /etc/init.d]$service telnetd start
Starting xinetd: [  OK  ]
[root@RHEL6 /etc/init.d]$service telnetd restart
Stopping xinetd: [  OK  ]
Starting xinetd: [  OK  ]
 
OK!
 
以上也仅仅是个人爱好,就当alias了一把,这其实也就是换了个名字而已,实际还是对服务xinetd进程操作!
不影响原服务
[root@RHEL6 /etc/init.d]$/etc/init.d/xinetd restart
Stopping xinetd: [  OK  ]
Starting xinetd: [  OK  ]
[root@RHEL6 /etc/init.d]$service xinetd restart
Stopping xinetd: [  OK  ]
Starting xinetd: [  OK  ]
 
其他参数
[root@RHEL6 /root]$/etc/rc.d/init.d/xinetd
Usage: /etc/rc.d/init.d/xinetd {start|stop|status|restart|condrestart|reload}
 
start:  启动这个服务。
stop:   停止这个服务。
restart:先停止,再启动,也就是重新启动的意思。
reload: 重新加载设定档,这个参数只有在服务已经启动的状况下才能使用。
condrestart:有条件的重新启动,这个服务必须是已经启动的,才会被重新启动;如果这个服务尚未启动,则无须启动之。
[root@RHEL6 /root]$/etc/rc.d/init.d/telnetd stop
Stopping xinetd: [  OK  ]
[root@RHEL6 /root]$/etc/rc.d/init.d/telnetd  condrestart
[root@RHEL6 /root]$/etc/rc.d/init.d/telnetd status
xinetd is stopped
status:察看目前服务的启动状态。
 
具体详见服务启动脚本
[root@RHEL6 /etc/init.d]$cat xinetd
#!/bin/bash
#
# xinetd        This starts and stops xinetd.
#
# chkconfig: 345 56 50
# description: xinetd is a powerful replacement for inetd. \
#              xinetd has access control mechanisms, extensive \
#              logging capabilities, the ability to make services \
#              available based on time, and can place \
#              limits on the number of servers that can be started, \
#              among other things.
#
# processname: /usr/sbin/xinetd
# config: /etc/sysconfig/network
# config: /etc/xinetd.conf
# pidfile: /var/run/xinetd.pid
 
 
### BEGIN INIT INFO
# Provides: 
# Required-Start: $network
# Required-Stop: 
# Should-Start: 
# Should-Stop: 
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: start and stop xinetd
# Description: xinetd is a powerful replacement for inetd. \
#              xinetd has access control mechanisms, extensive \
#              logging capabilities, the ability to make services \
#              available based on time, and can place \
#              limits on the number of servers that can be started, \
#              among other things.
### END INIT INFO
 
PATH=/sbin:/bin:/usr/bin:/usr/sbin
 
# Source function library.
. /etc/init.d/functions
 
# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network
 
# More config
 
test -f /etc/sysconfig/xinetd && . /etc/sysconfig/xinetd
 
RETVAL=0
 
prog="xinetd"
 
start(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write 
    # access to PID file
        [ $EUID -eq 0 ] || exit 4
 
    echo -n $"Starting $prog: "
 
# Localization for xinetd is controlled in /etc/synconfig/xinetd
    if [ -z "$XINETD_LANG" -o "$XINETD_LANG" = "none" -o "$XINETD_LANG" = "NONE" ]; then
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    else
        LANG="$XINETD_LANG"
        LC_TIME="$XINETD_LANG"
        LC_ALL="$XINETD_LANG"
        LC_MESSAGES="$XINETD_LANG"
        LC_NUMERIC="$XINETD_LANG"
        LC_MONETARY="$XINETD_LANG"
        LC_COLLATE="$XINETD_LANG"
        export LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    fi
    unset HOME MAIL USER USERNAME
    daemon $prog -stayalive -pidfile /var/run/xinetd.pid "$EXTRAOPTIONS"
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xinetd
    return $RETVAL
}
 
stop(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write 
    # access to PID file
        [ $EUID -eq 0 ] || exit 4
 
    echo -n $"Stopping $prog: "
    killproc -p /var/run/xinetd.pid $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xinetd
    return $RETVAL
 
}
 
reload(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
 
    echo -n $"Reloading configuration: "
    killproc $prog -HUP
    RETVAL=$?
    echo
    return $RETVAL
}
 
restart(){
    stop
    start
}
 
condrestart(){
    if [ -e /var/lock/subsys/xinetd ] ; then
        restart
        RETVAL=$?
        return $RETVAL
    fi
    RETVAL=0
    return $RETVAL
}
 
 
# See how we were called.
case "$1" in
    start)
        start
        RETVAL=$?
        ;;
    stop)
        stop
        RETVAL=$?
        ;;
    status)
        status $prog
        RETVAL=$?
        ;;
    restart)
        restart
        RETVAL=$?
        ;;
    reload|force-reload)
        reload
        RETVAL=$?
        ;;
    condrestart|try-restart)
        condrestart
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        RETVAL=2
esac
 
exit $RETVAL