
gpm Command in Linux
gpm stands for "General Purpose Mouse" and is a command used in Linux that provides mouse support for text-based consoles. This command allows you to use a mouse even when you are not in a graphical environment. It is particularly useful for tasks like copying and pasting text directly in the terminal. The gpm daemon captures mouse events and sends them to applications that can use this input.
Table of Contents
Here is a comprehensive guide to the options available with the gpm command −
- How to Install gpm Command?
- Syntax of gpm Command
- Options gpm Command
- Examples of gpm Command in Linux
How to Install gpm Command?
You may find gpm preinstalled on a few Linux distributions. However, in case it is unavailable, you can install it manually from your systems package manager.
On Debian-based Linux distributions like Ubuntu, the gpm can be installed using −
sudo apt install gpm
On Red Hat-based distributions like Fedora, CentOS, you can use −
sudo dnf install gpm
On Arch Linux, you can install it with −
sudo pacman -S gpm
On openSUSE, you can use −
sudo zypper install gpm
Managing gpm Service in Linux
Once you have installed the gpm utility, you must start its service using the following command:
sudo systemctl start gpm

You can also enable the gpm service to start at boot by using the below-given command:
sudo systemctl enable gpm

To ensure gpm service is running on your system, you can can execute the following command:
sudo systemctl status gpm

Syntax of gpm Command
The basic syntax to use the gpm command on Linux is given below −
gpm [options]
Where −
- gpm command is used to manage mouse events in virtual consoles.
- [options] are the various flags you can use to customize the behavior of the gpm command.
Options gpm Command
There are different options you can use with the gpm command, these are provided in the table below −
Option | Description |
---|---|
-A | Start with selection pasting disabled. |
-a | Set the acceleration value (default is 2). |
-B | Set the button sequence (e.g., 123 for normal, 321 for left-handed). |
-b | Set the baud rate (default is 1200). |
-D | Do not enter background operation automatically; useful for debugging. |
-d | Set the delta value for motion events. |
-g | Set the button (1-3) that is emulated by tapping on a glide point mouse. |
-h | Display help information. |
-i | Set the maximum time interval for multiple clicks (default is 250). |
-k | Kill a running gpm instance. |
-l | Load the inword() LUT (default is -a-zA-Z0-9_./?-??-??-?). |
-p | Force the pointer to be visible while selecting. |
-r | Set the responsiveness (default is 10). |
-S | Enable processing of a special command and allow changing the three special commands. |
-v | Display the version of gpm. |
Examples of gpm Command in Linux
Lets discuss a few examples of gpm command on Linux system −
- Setting Mouse Acceleration
- Disabling Selection Pasting on Startup
- Setting Baud Rate
- Changing Button Sequence
- Setting Delta Value
Setting Mouse Acceleration
You can use the gpm command on Linux to adjust your mouse acceleration in order to make the cursor move faster or slower based on the speed of your mouse movements. To set the mouse acceleration value, you can use the -a option followed by the desired value. For example −
sudo gpm -a 3
The above command will set the mouse acceleration to 3, and make the cursor move faster as you move the mouse. The default acceleration value is 2, but you can adjust it to suit your preferences.

Disabling Selection Pasting on Startup
If you want to disable the feature that allows text selection to be pasted automatically when starting the gpm daemon, you can use the -A option followed by a timeout value. Heres how you can do it −
sudo gpm -A 10
Once you execute the command, it will disable selection pasting with a timeout of 10 seconds. This can be useful if you find that accidental pasting is interfering with your workflow.

Setting Baud Rate
The baud rate helps to determine the speed at which data is transmitted between the mouse and the computer. To set the baud rate for the mouse, you can use the -b option followed by the desired baud rate. For example −
sudo gpm -b 2400
The above command will set the baud rate to 2400. The default baud rate is 1200, but you may need to adjust it depending on your mouse and system configuration.

Changing Button Sequence
You can also change the button sequence to accommodate different user preferences, such as for left-handed users. To do this, you can use the -B option followed by the desired button sequence. For example −
sudo gpm -B 321
The above command will change the button sequence to 321, which swaps the functions of the mouse buttons. This can be very useful for left-handed users that prefer a different button arrangement.

Setting Delta Value
The delta value affects how motion events are handled, and it helps to determine the sensitivity of the mouse movements. To set the delta value, you can use the -d option followed by the desired value. For example −
sudo gpm -d 5
The above command will set the delta value to 5, and make the mouse more sensitive to movements. You can adjust the delta value based on your preferences to achieve the desired level of precision for your tasks.
Conclusion
The gpm command is a Linux utility that facilitates mouse support in text-based consoles, allowing users to perform tasks like copying and pasting text directly within the terminal.
In this tutorial, we explained the installation process, syntax, and various options available for the gpm command. Additionally, we provided practical examples to help you effectively manage mouse events and enhance your productivity in a non-graphical environment. Once you master this command, you can significantly improve your efficiency when working in virtual consoles.