I created a new user by executing

sudo useradd -m harry

When I try to substitute the user by "su - harry" then everything I can see is a "$" (dollar) sign, the autocompletion isn't working and the shell builtins (e.g. source) are not available.

I checked .bashrc and .profile and detected that .bashrc is not getting sourced because $BASH_VERSION is not set.

The code inside .profile looks like follows:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

The command echo $BASH_VERSION returns nothing.



Shell builtins (source .bashrc, . .bashrc) don't work either.

The SHELL variable value was '/bin/sh' which is alias of dash. I changed it to /bin/bash (export SHELL=/bin/bash) but it didn't have any effects.

When I hardcode ". .bashrc" in .profile (of course, just to check if it would work) I receive several errors:

admin@host:~$ sudo su - harry
-su: 13: /home/harry/.bashrc: shopt: not found
-su: 21: /home/harry/.bashrc: shopt: not found
-su: 105: /home/harry/.bashrc: shopt: not found
-su: 28: /etc/bash_completion: [[: not found
-su: 34: /etc/bash_completion: [[: not found
-su: 51: /etc/bash_completion: Bad substitution
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ 

Any ideas how to fix it?

Thank you in advance. jepetko


This user's shell is /bin/sh. This is a smaller shell, which uses fewer resources than bash but offers fewer programming features and next to no interactive features.

Run sudo chsh -s /bin/bash harry to change the user's login shell to bash. This changes the user entry in /etc/passwd (don't edit that file directly unless you know what you're doing).

Setting the SHELL environment variable tells applications to run a different shell but has no effect on the currently running shell.

  • htis is actually the right way when the user already exists. – KGolbang Dec 12 '13 at 20:29

If you wish to create a user with the bash shell by default use this command:

useradd -m -s /bin/bash <userName>

Replace <userName> with the name of the user you wish to create.

  • hi Luis, I actually changed the SHELL variable to /bin/bash. okay, lets create a new user... It works! – KGolbang Dec 12 '13 at 20:28

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.