How to Reinstall USB Mouse Drivers in Ubuntu Using the Command Line

Techwalla may earn compensation through affiliate links in this story.
Image Credit: urbazon/iStock/GettyImages

There was a time when setting up a Linux system meant you'd spend hours tracking down and installing the right drivers for your hardware. In modern versions of the OS, like Ubuntu 18.04, that's no longer the case. Unless your computer is packed full of state of the art, bleeding-edge hardware, most things should work as soon as you install the operating system. Normally, the only time you need to install or reinstall something like a USB mouse driver is when you're using a nonstandard mouse with extra features.


How Linux Handles Mouse Drivers

You won't typically find an Ubuntu mouse driver or Linux mouse driver for an everyday, run-of-the-mill mouse. That's because standard USB mouse drivers are "baked in" to the operating system and handled by the OS's display server. In Ubuntu, the keyboard and mouse drivers are served by X Windows, just as they are in most other versions of Linux. There's a newer display server called Wayland, which is used by default in Fedora and available on Ubuntu, but it's not quite ready for prime time, so it's mostly used by developers and early adopters. In each case the mouse driver's code is built right in, so you won't be randomly uninstalling and reinstalling it. That will only happen if you're using a high-end mouse that requires a custom driver.


Video of the Day

It's a Community Thing

Because Linux mouse drivers are part of the OS, you probably won't find a custom driver from the mouse's manufacturer. It takes time and money to make and maintain one, and Linux gamers are a pretty small market niche, so there's not much motivation for companies like Logitech or Razr to make their own. Instead, those drivers usually come from projects within the Ubuntu or Linux community, ideally – though not always – with some degree of support from the manufacturer in the form of technical data. The driver is often packaged as a personal package archive, or PPA, which makes it easy to install from the command line. It'll also be automatically updated after it's installed, which is a great convenience.


Installing From a PPA

To reinstall your mouse using a custom driver, the first thing you need to do is tell Ubuntu where to find the PPA. To do this, you need to have administrator privileges at least temporarily, so each command will start with "sudo" to make you a superuser, and you need to enter your password to execute the command. If you were installing the OpenRazer driver for Razr gaming devices, for example, you'd type "sudo add-apt-repository ppa:openrazer/stable" without the quotes. This gives you administrator privileges, gives the command to add a repository, and then tells your computer to use the stable version of the driver from that source. Once you've added the PPA, type "sudo apt update" to find the new software and then "sudo apt install openrazer-meta" – again, always without the quotes – to install the driver. Once you're done, restart the computer. The details will vary, depending which driver you're installing, but the process is much the same. You should find the installation directions for your specific driver on the project's web page.


Install Ubuntu Mouse Driver From a .deb File

If the driver's creators haven't set it up as a package archive, you'll likely see it offered as a file with the .deb extension at the end. Those files can be used by Ubuntu or any other OS based on Debian, which is one of the main versions of Linux. The big advantage of a PPA over a .deb file is what are called "dependencies," other bits of software your driver needs before it can work. They come as part of a PPA, but with a .deb file, you need to make sure those are installed along with the driver. The "dpkg" command leaves you to do those individually, but the "gdebi" command does it automatically, so it's the better option for most users.


Using Gdebi to Install

First, download the .deb file for your mouse from the driver project's website. Be careful about which sites you trust for this because if the website is shady, you may end up with malware in addition to a driver. Once the driver is downloaded, type "sudo gdebi nameofdriver.deb" without the quotes and with the real name of your driver in place of "nameofdriver." If Ubuntu tells you it doesn't recognize the command, you need to install gdebi first. Type "sudo apt install gdebi-core" and then when gdebi is installed, repeat the command to install the mouse driver. Reboot your system, and the new driver should be active.