Disable / Enable Keyboard and Mouse in Linux

Sometimes, you may need to disable mouse and keyboard on a remote server / PC running X (i.e. over SSH) and Linux (or any other operating system running X).

Here is how to do it:

  • First, list the devices your X sees:
  • Now, list details for the mouse (id=3):
  • Disable the mouse:
  • Enable the mouse again:
  • Disable the keyboard:
  • Enable the keyboard again:
  • You may find more details in "man xinput".

How to Disable keyboard and mouse in Linux

To disable or enable the keyboard and mouse in Linux, you can use the xinput command to disable or enable input devices.

To disable an input device, you can use the following command:

Copy codexinput disable DEVICE_ID

Replace DEVICE_ID with the ID of the device you want to disable. You can find the ID of an input device by running xinput list.

To enable an input device that has been disabled, use the following command:

Copy codexinput enable DEVICE_ID

Again, replace DEVICE_ID with the ID of the device you want to enable.

Keep in mind that these changes are only temporary and will be reset when you restart your computer. If you want to make the changes permanent, you can add the xinput commands to a startup script that runs when your system boots up.

I hope this helps! Let me know if you have any questions or if you need further assistance.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.