Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

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.

share|improve this question

migrated from stackoverflow.com Oct 17 '12 at 8:28

This question came from our site for professional and enthusiast programmers.

+1 :) this is a funny accident – woliveirajr Oct 17 '12 at 12:13
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
@Johan What kind of substances did you take when you wrote this comment ? </kidding> – Luc M Aug 31 '13 at 19:25
up vote 110 down vote accepted

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

share|improve this answer
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
@JanSteinman Because then they would only have 6,330 points (6705 - 15 - 36*10). :P – ernie Oct 17 '12 at 23:35
@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
@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).

share|improve this answer
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
share|improve this answer
Thanks. But it gives error that xmodmap unable to open display `` – user13107 Oct 17 '12 at 5:42
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
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.

share|improve this answer
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.

share|improve this answer

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.

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.