Ssh Shell Prompt Does Not Show User@Host for One User

I have Ubuntu 12.04 server running. I created user1 when I installed, and created user2 today with '1useradd' and I added it to all the same groups as user1.

But when I log in remotely using SSH, the prompt for user1 looks like this:

user1@host:~$

And the prompt for user2 looks like this:

$

Most importantly, the shell doesn't behave as nicely as I'm used to when I'm logged in as user2. There is no autocomplete of commands or files with tab, and I can't access the MRU with up.

1

4 Answers

It is because their shell is set to /bin/sh, and not /bin/bash. You can use the program chsh (CHange SHell) to change that user's shell. When you're logged in as that user, run:

chsh /bin/bash

I would recommend against editing /etc/passwd manually as you could accidentally enter a syntactically wrong line in to it (without realising), which might break logins for other users.

2

Note: Use the method in the update, it's safer than manually editing passwd file.

the useradd command apparently sets /bin/sh as the default shell (which in turn is linked to /bin/dash). Try editing /etc/passwd and change /bin/sh to /bin/bash for user2.

In the future, use adduser instead.

UDPATE: As @Scott suggested below, instead of editing /etc/passwd use the chsh command:

chsh /bin/bash

Source:

2

While chsh gets the job done, just like one would modify several other aspects of a user, the usermod command is your friend:

usermod -s /bin/bash user

It is the editing counterpart of useradd.

When creating new users, you can specify the shell to use with the -s option.

useradd -m -s /bin/bash {username}

Note: -m creates the home directory.

However, if the user already exists, @Nachbars solution is the way to go:

usermod -s /bin/bash {username}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest