When I erroneously type 'ñ' (expecting to type any command) and then remove it and type the correct letter, the output returns the command with a special character attached , obviously the shell don't recognize the command and I must re-type it being careful not to type again the 'ñ' character.


Wrong typing       @tachomi:~$ ñs
Correct typing     @tachomi:~$ ls
Output             �ls: command not found
  • Why is this happening since I removed the wrong character?
  • How can I solve this?

What I think is that this kind of characters ñ , ' etc are not compatible with the shell being this the reason that the "memory" keeps something that it doesn't recognize, but I want to be sure why is this happening.

I'm using bash shell

  • When I type that in, bash tells me: bash: $'\303\261s': command not found, but ls continues to work normally. You might want to experiment with the builtin hash command: hash -l and hash -r Jan 23, 2015 at 20:07
  • 2
    Does not happen here... probably depend some strange LANG settings. In UTF-8 ñ is a two-bytes char, so you must have the terminal ignoring it. Which terminal are you using? How is LANG set?
    – Rmano
    Jan 23, 2015 at 20:08
  • @Rmano I'm using bash shell, how can I know the configured LANG?
    – tachomi
    Jan 23, 2015 at 20:15
  • 6
    <guessing> ñ is two bytes character and your backspace character for some reason deletes only one of them </guessing>
    – jimmij
    Jan 23, 2015 at 20:17
  • 1
    Tried it here on xterm and gnome-terminal and it works as expected, ([BackSpace] wipes ñ) but my lang is en_GB.UTF-8, so if you can reproduce this, could you test this by pressing [BackSpace] twice? Once for the first byte of the unicode character and once for the second???
    – Fabby
    Jan 23, 2015 at 20:54

3 Answers 3


You have a terminal (or terminal emulator) which understands multibyte encodings (probably UTF-8), but a shell which doesn't. Try setting the environment variable LANG to C.UTF-8. Or run locale -a to find another likely value to try.


Due to all help, I could find out how to fix this.

The main issue is due to the UTF-8 encoding, the server didn't have it configured as said in comments.

Quoting comments:

[@Rmano]: In UTF-8, ñ is a two-bytes char

[@jimmij]: backspace character for some reason deletes only one of them

[@aecolley]: Try setting the environment variable LANG to C.UTF-8

This is fixed as follows:

Find your current LANG    $ locale -v | grep 'LANG='
Output                    LANG=en_US
Change                    $ sudo LANG=en_US.UTF-8
Change                    $ sudo vim /etc/default/locale
Edit                      ~LANG="en_US.UTF-8"

Restart your terminal session.


You could run the following line of code:

if [[$(locale -v | grep 'LANG=') != *.UTF-8]]; then sudo $(locale -v | grep 'LANG=').UTF-8; fi

If the character code is not already UTF-8, it will set the character code to the UTF-8 version of the current character code. This way, the shell will understand UTF-8 characters, and will backspace them properly.

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.