Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am left handed person.
Therefore I want to interchange the typical mouse buttons for right and left clicks.

I want to do this via terminal. May someone please suggest the command for it?

Is it possible to interchange these clicks at the login screen also? I am using Ubuntu 12.04.

share|improve this question
up vote 14 down vote accepted
xmodmap -e "pointer = 3 2 1"

in a terminal should work. If you want to run that command at the start of lightdm (the default login screen), you can edit /etc/lightdm/lightdm.conf like described here - use the xmodmap command instead of xbacklight in the script, of course.

share|improve this answer
this works for the present session.. how to make it permanent??? – Fookraa Jun 16 '12 at 18:33
It should be permanent if you put it in /etc/lightdm/lightdm.conf. If not, you can put it in Startup Applications or create a .desktop file in ~/.config/autostart from the terminal. – elmicha Jun 16 '12 at 19:45

You can use also xinput to do this.

It will switch the buttons on one mouse only.

First use-

xinput list

To see where you mouse is will be somthing like

"USB Mouse"     id=12       [slave pointer]

So use the id number for the next command to switch the button assignment.

xinput set-button-map 12 3 2 1

So, you would switch out 12 with the id number of your mouse.

Source: 1

share|improve this answer
I find this useful because I often have two mice, left and right. This technique allows them to be set to be the mirror image of each other. – Rick-777 Jun 8 '15 at 9:13
And then you can make this permanent by creating a Xorg device configuration as explained here: – Apteryx Nov 19 '15 at 19:11
or just a startup script if you wish – Mateo Nov 19 '15 at 19:14

xmodmap is the command to change the mouse button mapping:

xmodmap -e "pointer = 3 2 1"

will remap the first three buttoons, left, middle and right, to act like , right, middle and left - not actually changing the middle button mapping.

That applies the change to the current session - more precisely, to the current X display, for exanple :0.

To save the change persistent over sessions, put the mapping into the file


If it does not exist, create it, liketouch ~/.Xmodmap

Edit it to add the line

pointer = 3 2 1

If there already is a pointer line, it may have some function, of course; Instead of replacing it, better modify the first three values - keeping a comment with the old:

For example,

pointer = 1 2 3 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24


!pointer = 1 2 3 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24
pointer = 3 2 1 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24

I'm used to ~/.Xmodmap allways just working; But see .Xmodmap works only when automatic login disabled? if it does not.

share|improve this answer

Execute this code in command prompt, it will remove and reset Optical mouse and touchpad to default- left click is for clicking and right click is for options.

modprobe -r psmouse
modprobe psmouse proto=imps
share|improve this answer

For Ubuntu ~12.04 and prior

#!/usr/local/bin/tcsh -fb

# switches between right and left mouse
set leftMouseHand = `gconftool-2 --get /desktop/gnome/peripherals/mouse/left_handed`
if ( "$leftMouseHand" == "false" ) then
    gconftool-2 --set /desktop/gnome/peripherals/mouse/left_handed true --type boolean
    gconftool-2 --set /desktop/gnome/peripherals/mouse/cursor_theme Oxygen_White_Big --type string
    gconftool-2 --set /desktop/gnome/peripherals/mouse/left_handed false --type boolean
    gconftool-2 --set /desktop/gnome/peripherals/mouse/cursor_theme Oxygen_White_Big --type string
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.