Linux性能优化之“关闭Ctrl+Alt+Del”

介绍: 

     Centos/redhat 操作系统只要按下Ctrl+Alt+Del快捷键,系统立马重启,而且不会有任何提示和确认,所以我们要严防此类事情的发生,针对不同的系统版本,相应的办法也是不一样的,具体如下:


Centos 5.x版本的操作系统

[[email protected]bdkyr ~]# cat /etc/inittab  

# Trap CTRL-ALT-DELETE 

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now   //默认为启用,在前面加上#号进行关闭


Centos 6.x版本的操作系统

[[email protected] 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文件

[[email protected] ~]# 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操作系统

[[email protected]bdkyr ~]# 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文件中的内容。

[[email protected]bdkyr ~]# 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


Linux性能优化之“关闭Ctrl+Alt+Del”