You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何创建X server重启的替代快捷键?避免误触CTRL+ALT+BACKSPACE

Fixing Accidental X Server Restarts: Add a Custom Shortcut

Got it, let's fix that super annoying accidental X server restart issue once and for all! Here's how you can set up a custom shortcut for restarting the X server—you can even keep (or ditch) the old Ctrl+Alt+Backspace combo, whatever works for you:

Method 1: Universal Xorg Config (Works for Most X11 Desktops)

This method sets the shortcut system-wide, so it'll work no matter which desktop environment you're using:

  • Open your Xorg keyboard config file. Depending on your distro, this might be /etc/X11/xorg.conf or /etc/X11/xorg.conf.d/00-keyboard.conf. You'll need sudo access for this, so run something like sudo nano /etc/X11/xorg.conf.d/00-keyboard.conf in the terminal.
  • Look for the Section "InputClass" block (it should be there for your keyboard). Add or modify the XkbOptions line to include your new shortcut. For example, to keep the old combo and add Ctrl+Shift+Backspace:
    Option "XkbOptions" "terminate:ctrl_alt_bksp,terminate:ctrl_shift_bksp"
    
    If you want to replace the old shortcut entirely, just remove terminate:ctrl_alt_bksp from the line. You can also use other combinations like terminate:alt_shift_bksp for Alt+Shift+Backspace.
  • Save the file (in nano, that's Ctrl+O then Enter, followed by Ctrl+X to exit). Log out and back in, or restart your X server, and the new shortcut will take effect.

Method 2: Desktop Environment-Specific Shortcuts (More Intuitive)

If you prefer using your desktop's built-in settings tool, here's how to do it for popular environments:

GNOME

  1. Open Settings → Keyboard Shortcuts.
  2. Scroll all the way to the bottom and click Add Custom Shortcut.
  3. Name it something like "Restart X Server", then set the command to sudo killall -TERM Xorg. (Note: You'll need to let your user run this command without a password first—see the tip below.)
  4. Click Set Shortcut and press the combo you want (like Ctrl+Shift+Backspace), then hit Add.

KDE Plasma

  1. Open System Settings → Shortcuts → Custom Shortcuts.
  2. Click Edit → New → Global Shortcut → Command/URL.
  3. Name your shortcut, paste sudo killall -TERM Xorg as the command, then switch to the Trigger tab and set your desired key combo.

Xfce

  1. Open Settings Manager → Keyboard → Application Shortcuts.
  2. Click Add, paste sudo killall -TERM Xorg as the command, then press your preferred key combo when prompted.

Important Tip for the Desktop Method:

To avoid entering your password every time you use the shortcut, edit the sudoers file to allow the command without authentication:

  • Run sudo visudo in the terminal.
  • Add this line at the bottom (replace your_username with your actual username):
    your_username ALL=(ALL) NOPASSWD: /usr/bin/killall -TERM Xorg
    
  • Save and exit (in visudo, that's Ctrl+O then Enter, followed by Ctrl+X).

Method 3: Temporary Shortcut (Current Session Only)

If you just want to test a new shortcut without changing any config files, run this in the terminal:

setxkbmap -option terminate:ctrl_shift_bksp

This enables Ctrl+Shift+Backspace for the current session only. To keep the old combo alongside it, use:

setxkbmap -option terminate:ctrl_alt_bksp,terminate:ctrl_shift_bksp

Quick Note:

Remember—restarting the X server will close all your open apps, so make sure you save your work before using any of these shortcuts!

内容的提问来源于stack exchange,提问作者Shayan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:55:21