Producing a specific ASCII character in Ubuntu

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.


Solution 1:

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!

Solution 2:

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'
\