Linux默认允许任何人按下Ctrl+Alt+Del重启系统。但是在生产环境中,应该停用按下Ctrl-Alt-Del 重启系统的功能。前面的centos版本都是在/etc/inittab中配置,而centos7/RHEL7查看/etc/inittab文件,“Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target”指出了这个功能键在“/usr/lib/systemd/system/ctrl-alt-del.target”设置。  

[root@ansible-node1 ~]# 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
#




Linux CentOS7/RHEL7关闭ctrl+alt+delete功能键_关闭ctrl+alt+delete功能键

    直接vim编辑这个文件,按以往设置关闭这个功能的方式去操作:全部注释掉/usr/lib/systemd/system/ctrl-alt-del.target文件中的内容即可。但是由于此文件是/usr/lib/systemd/system/reboot.target的软链接文件,这样的话会使reboot命令失效,因此要想解决这个问题只需要删除文件:/usr/lib/systemd/system/ctrl-alt-del.target即可,同时执行#init q重新加载配置文件使配置生效,此时Ctrl+Alt+Del失效,同时reboot也能用,恢复ctrl+ALt+Del只需将reboot.target文件软链接成ctrl-alt-del.target即可。即

  # ln -s /usr/lib/systemd/system/reboot.target /usr/lib/systemd/system/ctrl-alt-del.target
  
具体操作过程:

[root@centos7 tmp]# find / -name reboot.target
/usr/lib/systemd/system/reboot.target
[root@centos7 ~]# ll /usr/lib/systemd/system/ctrl-alt-del.target
lrwxrwxrwx 1 root root 13 Jul 11 18:19 /usr/lib/systemd/system/ctrl-alt-del.target -> reboot.target
[root@centos7 ~]#
[root@centos7 ~]# ll /usr/lib/systemd/system/reboot.target
-rw-r--r-- 1 root root 543 Jul 11 18:12 /usr/lib/systemd/system/reboot.target
[root@centos7 ~]#
[root@centos7 ~]# rm -rf /usr/lib/systemd/system/ctrl-alt-del.target
[root@centos7 ~]# init -q