When logging in as root at my server everything works fine, but when I log in as myusername the bash is not working correctly.

The line starts with:

$ 

instead of

myusername@myserver:~$

and all specials keys like the arrow keys, tab keys, etc. won't work.

When I type bin/bash it works again, but I'd like to fix the problem or auto run bin/bash on login. How can I fix this?

migrated from serverfault.com Oct 8 '12 at 18:49

This question came from our site for system and network administrators.

up vote 15 down vote accepted

You just need to change your shell. As that user, run:

$ chsh -s /bin/bash

Then sign out and back in.

After doing this the prompt doesn't look like you want, you'll need to start tweaking your environment's PS1 variable.

  • This is actually kind of dangerous since the question is asking about the root user. He's likely not using Linux. Root should stay with the default shell since the vendor is probably going to count on it being ksh or whatever else they chose. Instead, the real answer is "you shouldn't be logging in as root anyway". – bahamat Oct 8 '12 at 22:22

You need to change your shell. Run the command

chsh -s /bin/bash

then sign in again.

However, not all users have the right to change their own shell. If you use sudo remember to add your username to the chsh command as

sudo chsh <username> -s /bin/bash

otherwise you will change the shell for root inadvertently.

  • Fair point. Extended the answer slightly. – Mikael Fremling May 13 '14 at 13:00
  • I was very naive to try: sudo chsh -s /bin/bash since my user didn't have permission to change shell. Your answer helped me solve it. Thanks! – Edenshaw Feb 2 at 15:08

One possible reason is that the default shell of myusername is not bash.

You can check the shell of your current user with:

  • echo ${SHELL}
  • echo $0

To change the user shell permanently see man chsh , e.g.:

chsh -s /bin/bash

If your sudo user password is disabled, you can edit the /etc/passwd directly, find the line where your user is and change the shell path into /bin/bash.

Here is the explanation of /etc/passwd format.

Just wanted to add one more thing.

If sudo access is required to change the bash for that user, then you need to mention your username as well in the sudo command since without username it will apply to the root user.

$ sudo chsh -s /bin/bash <user>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.