2

Some time back I added an user on Debian X64 server, and instead of showing me the username when I ssh into the machine, it shows me weird characters as shown in screenshot below. Please note, it does not happen for root or postgres, only for this user. Also disabled is when I press tab or up-arrow, I don't get auto-complete or previous command, just space or random characters respectively. How to fix this?

Screenshot

Kindly let me know what I can do. Thank you.

2
  • Change your default shell of your user to /bin/bash, login as root, chsh -s /bin/bash deploy.
    – cuonglm
    Nov 30, 2015 at 8:28
  • @cuonglm : Thanks, that worked. Can you tell me what mistake I made while creating this user which caused this problem. Also, kindly create an answer for me to accept. Thank you. :-) Nov 30, 2015 at 8:37

2 Answers 2

4

In Debian system, if you create user with useradd without a specified shell (using -s option), the user default shell will be set to /bin/sh, which is linked to /bin/dash instead of /bin/bash, starting from Squeeze:

$ grep SHELL= /etc/default/useradd
SHELL=/bin/sh

dash is a POSIX-compliant shell and do not have some extended features like bash.

You must change your user default login shell to /bin/bash:

chsh -s /bin/bash deploy

You also need to change SHELL=/bin/sh to SHELL=/bin/bash in /etc/default/useradd to make it system wide.

1
  • That was an awesome advice. Changed default settings, just don't know why they still use sh if there is bash available for default users. Thanks a lot. :-) Nov 30, 2015 at 9:20
0

This happens when the colors or other special characters are defined in environmental variable PS1, but the terminal, for whatever reason, is unable to display them. PS1 is the env variable that defines how the shell prompt will appear. You may need to revert to defaults (google: bash ps1 default) or you may need to do something like :

export TERM=linux

Check out the bash man page for more info.

2
  • Setting TERM manually rarely solves anything (and when it does, it isn't set to linux), and definitely won't help here. Nov 30, 2015 at 22:28
  • This really isn't accurate. Either way, I've solved exactly this problem in the past several times by correctly setting TERM to "linux" (from vt100, null, etc.). I'll concede, however, that my answer may not widely apply to today's systems
    – nod
    Dec 1, 2015 at 19:38

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.