现任职北京某互联网公司运维经理,高级架构师,涉足互联网运维行业已经超过10年。曾服务于京东商城,互动百科等互联网公司,早期运维界新星。 长期专研,C语言开发,操作系统内核,大型互联网架构。http://www.bdkyr.com
全部博文(166)
分类: 系统运维
2017-03-13 14:41:18
介绍:
Centos/redhat 操作系统只要按下Ctrl+Alt+Del快捷键,系统立马重启,而且不会有任何提示和确认,所以我们要严防此类事情的发生,针对不同的系统版本,相应的办法也是不一样的,具体如下:
Centos 5.x版本的操作系统
[root@ ~]# cat /etc/inittab
# Trap CTRL-ALT-DELETE
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now //默认为启用,在前面加上#号进行关闭
Centos 6.x版本的操作系统
[root@rac1 grub]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf #关键点
由此可以看到在Centos 6.x中该参数已被移动到另外一个配置文件/etc/init/control-alt-delete.conf中了
查看/etc/init/control-alt-delete.conf文件
[root@bdkyr ~]# cat /etc/init/control-alt-delete.conf
# control-alt-delete - emergency keypress handling
#
# This task is run whenever the Control-Alt-Delete key combination is
# pressed. Usually used to shut down the machine.
start on control-alt-delete
#exec /sbin/shutdown -r now "Control-Alt-Delete pressed" //在前面用#号注释掉
centos7.x操作系统
[root@ ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
现在我们知道了Ctrl+Alt+Del在/usr/lib/systemd/system/ctrl-alt-del.target中配置。
那我们直接vim编辑这个文件,按以往设置关闭这个功能的方式去操作:全部注释点/usr/lib/systemd/system/ctrl-alt-del.target文件中的内容。
[root@ ~]# vim /usr/lib/systemd/system/ctrl-alt-del.target
#[Unit]
#Description=Reboot
#Documentation=man:systemd.special(7)
#DefaultDependencies=no
#Requires=systemd-reboot.service
#After=systemd-reboot.service
#AllowIsolate=yes
#[Install]
#Alias=ctrl-alt-del.targe