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.

  • 5
    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 '13 at 16:14
  • 3
    @Johan What kind of substances did you take when you wrote this comment ? </kidding> – Luc M Aug 31 '13 at 19:25

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).

  • 5
    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.) – Jan Steinman Oct 17 '12 at 21:29
  • 5
    @JanSteinman Because then they would only have 6,330 points (6705 - 15 - 36*10). :P – ernie Oct 17 '12 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 '12 at 10:25
  • Thanks for accepting some good-natured ribbing -- no slight intended at all. If you know it, show it! – Jan Steinman Oct 19 '12 at 0:09
  • 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 '12 at 20:19

In a terminal window (I tested only aterm, rxvt, vte and xterm) you can select the end of line, which pasted back has the effect of pressing Enter:

#          ____________type the command____________  __select to end of line__
#         /                                        \/                         \
bash-4.2$ xmodmap -e "keycode 135 = Pointer_Button2"

Then paste the selected text back in the terminal window with the middle mouse button click (or with simultaneous left and right mouse button click, if configured so).

  • 1
    Cool! I thought there is no way to copy-paste unprintable characters. – user13107 Oct 17 '12 at 8:43

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 '12 at 5:42
  • 1
    You can give it a display with DISPLAY="0", or edit the file, should be in $HOME/.Xmodmap – Burhan Khalid Oct 17 '12 at 5:45
  • 6
    Small typo: DISPLAY=:0 – Lekensteyn Oct 17 '12 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 '12 at 5:50
  • Ok. It works after changing the file properties. – user13107 Oct 17 '12 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 '17 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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