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」設置。 node
[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.targetvim
直接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便可。即centos
# ln -s /usr/lib/systemd/system/reboot.target /usr/lib/systemd/system/ctrl-alt-del.target