Accidently I mapped Enter via xkbset to Pointer_button2.

Now every time I hit Enter some gibberish text appears.

I thought of a workaround involving remapping it back, but that means I will have to run a command xmodmap -e "keycode 135 = Pointer_Button2" (or any other keycode but that of Enter). But I'm not able to run this command in terminal, without hitting Enter.

How do I do so?

I'm running Ubuntu 12.04.

  • 6
    One day computers will be able to undo anything. Like we have with file system snapshots now, but with the contents of RAM... like rolling back what we are doing. Un-enter a command. Un-open a file. Un-run a program. Un-Do last 5 minutes. Then, later the internet will catch up ... Un-read a web-site: You were never there! Maybe one day we will be able to un-do motor car accidents, restore the lamp posts to upright, etc.
    – Johan
    Mar 15, 2013 at 16:14
  • 4
    @Johan What kind of substances did you take when you wrote this comment ? </kidding>
    – Luc M
    Aug 31, 2013 at 19:25

6 Answers 6


You can use CTRL+J or CTRL+M as an alternative to Enter. They are the control characters for linefeed (LF) and carriage return (CR).

  • 6
    Sheesh… why can't folks with 6,705 points let some of these easy questions through to the vast unwashed masses to answer? (Just kidding -- +1 for the answer I was going to post.) Oct 17, 2012 at 21:29
  • 5
    @JanSteinman Because then they would only have 6,330 points (6705 - 15 - 36*10). :P
    – ernie
    Oct 17, 2012 at 23:35
  • 3
    @JanSteinman: I did let it through! There were already three other answers when I answered, and one was accepted. It seems kids these days don't know their ASCII :-) (@ernie: there's a daily reputation cap, so you don't get all those points).
    – camh
    Oct 18, 2012 at 10:25
  • 2
    @user13107 Not so much historical as just the ASCII code definition itself. When ASCII was pretty much all there was (unless you were in IBM land) the Return and Linefeed keys had to be coded as something so we could type them on our trusty ASR-33 teletypes or our punch cards. There's even an ascii package you can install that will display it. The Ctrl key just took the code for one of the first 32 characters and set one bit back to 0. For M, it changed a 4D to a 0D which is a carriage return (and there really was a carriage on an ASR-33.)
    – Joe
    Oct 20, 2012 at 20:19
  • 1
    @Utku - They had those keys, but they only had 8 bits to play with and one of them was for rubouts - so characters on the paper tapes could be "erased". With 7 bits, things got pretty squashed together. Another was the difference between lower and uppercase. Another was for Ctrl. That left just 6 bits to get everything else done. So the Return key really just sent the same code as Ctrl+M and the Linefeed key just sent Ctrl-J. It was an artifact of the hardware/coding limitations. It was amazing how much they squeezed out of that little!
    – Joe
    May 16, 2016 at 8:54

Run the command from a non-X terminal.

CTRL+ALT+F2 should get you to a normal console. Login as your normal user, and then run the command there.

xmodmap only affects X sessions so it needs DISPLAY to work outside the X server, like this:

DISPLAY=:0 xmodmap
  • Thanks. But it gives error that xmodmap unable to open display ``
    – user13107
    Oct 17, 2012 at 5:42
  • 1
    You can give it a display with DISPLAY="0", or edit the file, should be in $HOME/.Xmodmap Oct 17, 2012 at 5:45
  • 6
    Small typo: DISPLAY=:0
    – Lekensteyn
    Oct 17, 2012 at 9:55

You could put it into a script (.sh) and then double click it. Most modern desktop environments give the option of running a script instead of opening it in a text file.

  • Thanks. Tried it. Didn't find the option of running it as a script.
    – user13107
    Oct 17, 2012 at 5:50
  • Ok. It works after changing the file properties.
    – user13107
    Oct 17, 2012 at 8:40

If you have a mouse and graphical display you can copy the end of a previous line in your terminal and paste it onto the end of your command.


CTRL+O is another option. With bash it executes the command and moves to the next most recent in history, it is useful to cycle back through a chain of previously executed commands.


If you have a mouse then just copy this -> "


and paste next to your command and then paste entire command in the terminal.

Like enter image description here

  • This has already been given as an answer
    – Philippos
    May 3, 2017 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .