Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm used to holding the left Alt and entering the ASCII character whenever I'm using an unknown keyboard configuration and want to type a special character.

For example, Alt + 0 + 9 + 2 makes a backslash (\).

That's on Windows. Is there a way to do this in Ubuntu?

Note: I also want to be able to use this in console mode. That means I don't want a solution involving software with a GUI.

share|improve this question
add comment

4 Answers

up vote 7 down vote accepted

If you are using Gnome (stock Ubuntu does) you can do that by holding down both the Ctrl and Shift keys and typing u followed by the hexadecimal value of the character.

To produce the backslash \, you would hold Ctrl + Shift and press U, 5 and C.

On Windows you type the decimal value while on Linux you type the hexadecimal value (which is usually shorter if you go in the higher numbers). The u stands for Unicode.

A pretty complete table of hexadecimal values can be found here. Warning, page can take a long time to load!

share|improve this answer
The "hexadecimal value" is in fact the Unicode codepoint, unlike "Alt codes" which are ASCII –  grawity Oct 7 '10 at 18:33
Wow. Exactly what I needed ! Works everywhere like a charm. Thank you. –  Philippe Carriere Oct 12 '10 at 15:08
Now I only need to learn all the codes in hexa.... :( –  Philippe Carriere Oct 12 '10 at 15:14
add comment

Another option (but it does not insert a character by ASCII/Unicode code) is to activate the ComposeKey (like right Alt in my case), so that you can then type things like:

  • Alt + = + e → €
  • Alt + ' + e → é
  • Alt + ^ + e → ê

etc. In case you want to enter frequently used latin letters (as in Spanish, French, etc), this might be faster than having to learn the Unicode code points. It's all about having choice!

share|improve this answer
Don't you need an non-US keyboard layout for this? –  Cristian Ciupitu Jun 1 at 0:23
add comment

Linux's console driver doesn't have a facility for entering characters this way... but it isn't really needed since shells can handle this themselves.

$ echo $'\x5c'
share|improve this answer
Thats a very nice method.... I can't even find it in the man pages of echo but it works! Is there a way to provide the decimal code instead of the hexidecimal one ? (I learned the decimal codes by heart) –  Philippe Carriere Oct 7 '10 at 13:15
Is there a way to use this when I'm in vi or nano ? –  Philippe Carriere Oct 7 '10 at 13:17
No, they can only be entered in hex (\xNN) or octal (\NNN). You can use printf if you want to see the hex code for a value. In vim you can type Ctrl-V U and then the 4-digit Unicode codepoint. Also, QUOTING section. –  Ignacio Vazquez-Abrams Oct 7 '10 at 14:06
@Silence: (1) Because it's a feature of your shell (usually bash), not of echo. –  grawity Oct 7 '10 at 18:33
add comment

Take it from http://www.cl.cam.ac.uk/~mgk25/unicode.html

Extend your keyboard mapping using xmodmap. This is particularly convenient if your keyboard has an AltGr key, which is meant for exactly this purpose (some US keyboards have instead of AltGr just a right Alt key, others lack that key entirely unfortunately, in which case some other key must be assigned the Mode_switch function). Write a file "~/.Xmodmap" with entries such as

  keycode 113 = Mode_switch Mode_switch
  keysym d = d NoSymbol degree        NoSymbol
  keysym m = m NoSymbol emdash        mu
  keysym n = n NoSymbol endash        NoSymbol
  keysym 2 = 2 quotedbl twosuperior   NoSymbol
  keysym 3 = 3 sterling threesuperior NoSymbol
  keysym 4 = 4 dollar   EuroSign      NoSymbol
  keysym space = space  NoSymbol      nobreakspace NoSymbol
  keysym minus = minus  underscore    U2212        NoSymbol
  keycode 34 = bracketleft  braceleft  leftsinglequotemark  leftdoublequotemark
  keycode 35 = bracketright braceright rightsinglequotemark rightdoublequotemark
  keysym KP_Subtract = KP_Subtract NoSymbol U2212    NoSymbol
  keysym KP_Multiply = KP_Multiply NoSymbol multiply NoSymbol
  keysym KP_Divide   = KP_Divide   NoSymbol division NoSymbol

and load it with "xmodmap ~/.Xmodmap" from your X11 startup script into your X server. You will then find that you get with AltGr easily the following new characters out of your keyboard:

share|improve this answer
add comment

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.