CentOS6.2关闭tty的方法
时间:2014-09-17 20:39 来源:linux.it.net.cn 作者:it
在linux系统中,一般情况,只需开启两个tty终端,没有必要开启多余的tty进程,以减少tty进程对系统资源的开销。
复制代码代码示例:
[root@nginx etc]# ps -aux|grep tty #查看tty进程
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1636 0.0 0.0 4056 552 tty2 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty2
root 1638 0.0 0.0 4056 548 tty3 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty3
root 1640 0.0 0.0 4056 548 tty4 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty4
root 1642 0.0 0.0 4056 552 tty5 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty5
root 1648 0.0 0.0 4056 552 tty6 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty6
root 1723 0.0 0.1 108328 1776 tty1 Ss+ 09:07 0:00 -bash
root 2344 0.0 0.0 103244 840 pts/0 S+ 10:29 0:00 grep tty
[root@nginx etc]# vi /etc/init/start-ttys.conf
复制代码代码示例:
# This service starts the configured number of gettys.
start on stopped rc RUNLEVEL=[2345]
env ACTIVE_CONSOLES=/dev/tty[1-2] #将tty[1-6]修改为[1-2]
env X_TTY=/dev/tty1
task
script
. /etc/sysconfig/init
for tty in $(echo $ACTIVE_CONSOLES) ; do
[ "$RUNLEVEL" = "5" -a "$tty" = "$X_TTY" ] && continue
initctl start tty TTY=$tty
done
end script
[root@nginx etc]# vi /etc/sysconfig/init
复制代码代码示例:
# What ttys should gettys be started on?
ACTIVE_CONSOLES=/dev/tty[1-2] #将tty[1-6]修改为[1-2]
# Set to '/sbin/sulogin' to prompt for password on single-user mode
# Set to '/sbin/sushell' otherwise
SINGLE=/sbin/sushell
修改以上配置文件需重启系统生效,如果要临时停止tty终端,可使用 如:initctl stop tty TTY=/dev/tty6 [停止tty6]。
复制代码代码示例:
[root@nginx etc]# ps -aux|grep tty
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1636 0.0 0.0 4056 552 tty2 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty2
root 1638 0.0 0.0 4056 548 tty3 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty3
root 1640 0.0 0.0 4056 548 tty4 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty4
root 1642 0.0 0.0 4056 552 tty5 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty5
root 1723 0.0 0.1 108328 1776 tty1 Ss+ 09:07 0:00 -bash
root 2358 0.0 0.0 103244 844 pts/0 S+ 10:31 0:00 grep tty
(责任编辑:IT)
在linux系统中,一般情况,只需开启两个tty终端,没有必要开启多余的tty进程,以减少tty进程对系统资源的开销。
复制代码代码示例:
[root@nginx etc]# ps -aux|grep tty #查看tty进程
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ root 1636 0.0 0.0 4056 552 tty2 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty2 root 1638 0.0 0.0 4056 548 tty3 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty3 root 1640 0.0 0.0 4056 548 tty4 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty4 root 1642 0.0 0.0 4056 552 tty5 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty5 root 1648 0.0 0.0 4056 552 tty6 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty6 root 1723 0.0 0.1 108328 1776 tty1 Ss+ 09:07 0:00 -bash root 2344 0.0 0.0 103244 840 pts/0 S+ 10:29 0:00 grep tty
[root@nginx etc]# vi /etc/init/start-ttys.conf
复制代码代码示例:
# This service starts the configured number of gettys.
start on stopped rc RUNLEVEL=[2345] env ACTIVE_CONSOLES=/dev/tty[1-2] #将tty[1-6]修改为[1-2] env X_TTY=/dev/tty1 task script . /etc/sysconfig/init for tty in $(echo $ACTIVE_CONSOLES) ; do [ "$RUNLEVEL" = "5" -a "$tty" = "$X_TTY" ] && continue initctl start tty TTY=$tty done end script
[root@nginx etc]# vi /etc/sysconfig/init
复制代码代码示例:
# What ttys should gettys be started on?
ACTIVE_CONSOLES=/dev/tty[1-2] #将tty[1-6]修改为[1-2] # Set to '/sbin/sulogin' to prompt for password on single-user mode # Set to '/sbin/sushell' otherwise SINGLE=/sbin/sushell
修改以上配置文件需重启系统生效,如果要临时停止tty终端,可使用 如:initctl stop tty TTY=/dev/tty6 [停止tty6]。
复制代码代码示例:
[root@nginx etc]# ps -aux|grep tty
(责任编辑:IT)Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ root 1636 0.0 0.0 4056 552 tty2 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty2 root 1638 0.0 0.0 4056 548 tty3 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty3 root 1640 0.0 0.0 4056 548 tty4 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty4 root 1642 0.0 0.0 4056 552 tty5 Ss+ 09:07 0:00 /sbin/mingetty /dev/tty5 root 1723 0.0 0.1 108328 1776 tty1 Ss+ 09:07 0:00 -bash root 2358 0.0 0.0 103244 844 pts/0 S+ 10:31 0:00 grep tty |