In CentOS/RHEL 7, /etc/init/control-alt-delete.override no more works to override the key combination. The post provides the procedure to disable “alt+ctrl+del” key combination in order to prevent an accidental shutdown.

 

Masking the ctrl-alt-del.target Target

 

1. If requirement is to disable the “ctrl+Alt+delete” key combination, one need to mask a service. This is like disabling a service. Run the following command:

# systemctl mask ctrl-alt-del.target

or

# ln -sf /dev/null /etc/systemd/system/ctrl-alt-del.target

 

2. systemd will recognize units symlinked to /dev/null and show them as masked. If one try to send key combination, this will fail with following similar error.

June 9 02:33:43 geeklab systemd: Failed to enqueue ctrl-alt-del.target job: Unit ctrl-alt-del.target is masked.

 

3. However, above steps will not disable “ctrl+Alt+delete” key combination, in GUI mode. To disable it in GUI change keyboard settings.

Navigate to  Applications -> System Tools -> Settings -> Keyboard  -> Shortcuts -> System 
Set value of "Logout" as Disabled

 

Unmasking the ctrl-alt-del.target Target

 

To unmask the ctrl-alt-del.target Target and revert back, run the following command:

# systemctl unmask ctrl-alt-del.target

 

 

Disabling “ctrl-alt-del.target Target” in GUI mode, using CLI

 

Use the steps below to disable the “Alt+Ctrl+Del” key combination in GUI, using CLI.

 

Disabling per user

 

1. We need to check the value of “DBUS_SESSION_BUS_ADDRESS” environment variable from the already logged in GNOME. For example, a `testuser` has already logged in to the GNOME, and form the GNOME terminal, we use the following command:

$ env | grep DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-3UIRkKkjAU,guid=15771e3a5dcb3a7b2c151d00566a2dda

 

2. Mark down the output and then turn to the ssh session and export it:

$ export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-3UIRkKkjAU,guid=15771e3a5dcb3a7b2c151d00566a2dda

 

3. Now we can use gsettings to set the value of the key:

$ gsettings set org.gnome.settings-daemon.plugins.media-keys logout ''

 

4. Check if the key is successfully modified:

$ gsettings get org.gnome.settings-daemon.plugins.media-keys logout
''

 

Disabling for all users

 

1. Create a file under the directory ‘/etc/dconf/db/local.d/‘ with the settings to be applied globally. For example:

# cat /etc/dconf/db/local.d/00-disable-CAD 
[org/gnome/settings-daemon/plugins/media-keys]
logout=''

 

2. Update the dconf settings:

# dconf update

 

Verify if the ‘ctrl-alt-del’ key combination is disabled globally.

 

Esta resposta lhe foi útil? 0 Usuários acharam útil (0 Votos)