redhat禁止ctrl+alt+delete

redhat6.x下适用

测试环境为redhat6.8

[root@node1 ~]# vim /etc/inittab

查看第9行发现控制Ctrl-Alt-Delete的配置文件位于/etc/init/control-alt-delete.conf

  1 #inittab is only used by upstart for the default runlevel.

  2 #

  3 #ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.

  4 #

  5 #System initialization is started by /etc/init/rcS.conf

  6 #

  7 #Individual runlevels are started by /etc/init/rc.conf

  8 #

  9 #Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf

 10 #

 11 #Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,

 12 #with configuration in /etc/sysconfig/init.

 13 #

 14 #For information on how to write upstart event handlers, or how

 15 #upstart works, see init(5), init(8), and initctl(8).

 16 #

 17 #Default runlevel. The runlevels used are:

 18#   0 - halt (Do NOT set initdefault tothis)

 19#   1 - Single user mode

 20#   2 - Multiuser, without NFS (The sameas 3, if you do not have networking)

 21#   3 - Full multiuser mode

 22#   4 - unused

 23#   5 - X11

 24#   6 - reboot (Do NOT set initdefault tothis)

 25 #

 26id:3:initdefault: 


[root@node1 ~]# vim/etc/init/control-alt-delete.conf

将配置文件的第9行注释,不需要重启设备(最好输入init q重新加载配置文件)。在字符界面按下control-alt-delete就不会重启设备。注意:该配置对图形界面不生效,图形下依旧会出现提示重启、关机等的界面框。

  1 #control-alt-delete - emergency keypress handling

  2 #

  3 #This task is run whenever the Control-Alt-Delete key combination is

  4 #pressed.  Usually used to shut down themachine.

  5 #

  6 #Do not edit this file directly. If you want to change the behaviour,

  7 #please create a file control-alt-delete.override and put your changes there.

  8

  9#start on control-alt-delete

 10

 11exec /sbin/shutdown -r now "Control-Alt-Delete pressed"

redhat7.x下适用

测试环境为redhat7.4

[root@localhost ~]# cat /etc/inittab

# inittab is no longer used when usingsystemd.

#

# ADDING CONFIGURATION HERE WILL HAVE NOEFFECT ON YOUR SYSTEM.

#

# Ctrl-Alt-Delete is handled by/usr/lib/systemd/system/ctrl-alt-del.target

#

# systemd uses 'targets' instead ofrunlevels. By default, there are two main targets:

#

# multi-user.target: analogous to runlevel3

# 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

[root@localhost ~]# ll/usr/lib/systemd/system/ctrl-alt-del.target

lrwxrwxrwx. 1 root root 13 Feb  4 11:52/usr/lib/systemd/system/ctrl-alt-del.target -> reboot.target


[root@localhost ~]# vim/usr/lib/systemd/system/ctrl-alt-del.target

编辑文件,从第9行开始直到19行全部注释掉,即会发现reboot命令也失效。

  1#  This file is part of systemd.

  2 #

  3#  systemd is free software; you canredistribute it and/or modify it

  4#  under the terms of the GNU LesserGeneral Public License as published by

  5#  the Free Software Foundation; eitherversion 2.1 of the License, or

  6#  (at your option) any later version.

  7

  8#[Unit]

  9#Description=Reboot

 10#Documentation=man:systemd.special(7)

 11#DefaultDependencies=no

 12#Requires=systemd-reboot.service

 13#After=systemd-reboot.service

 14#AllowIsolate=yes

 15#JobTimeoutSec=30min

 16#JobTimeoutAction=reboot-force

 17

 18#[Install]

 19#Alias=ctrl-alt-del.target


[root@localhost system]# pwd

/usr/lib/systemd/system

[root@localhost system]# rm -rfctrl-alt-del.target

[root@localhost system]# init q      -->重新加载配置文件生效

直接将“/usr/lib/systemd/system”路径下的ctrl-alt-del.target删除即会发现按1次ctrl+alt+delete组合键失效,同时每次按ctrl+alt+delete组合键的时间间隔在1s或1s以上,组合键同样失效;但按组合键的速度很快,达到每次的时间间隔小于1s则一共按8次同样会发生重启(应该是bug)。

如果要恢复ctrl+alt+delete组合键,则重新创建链接即可

# ln -s/usr/lib/systemd/system/reboot.target/usr/lib/systemd/system/ctrl-alt-del.target


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值