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

         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
#

  # ll /usr/lib/systemd/system/ctrl-alt-del.target
    lrwxrwxrwx. 1 root root 13 May 26 2017 /usr/lib/systemd/system/ctrl-alt-del.target -> reboot.target

 

    直接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

posted @ 2017-08-30 12:07  静念  阅读(3823)  评论(1编辑  收藏  举报