I'm using Ubuntu 19 and I created a few users already. On the latest user I created and tried to do a:

su userx

I login with only the $ prompt, but when I type "bash" as that user I get: userx@myhost:

My other users all login as user@myhost. Why is that user going directly to $ prompt? Also none of my paths work it seems. When I type ll it doesnt work until I type "bash".

  • 1
    check the use of the - operator, so you would do su - userx which should then spawn a normal login type session, which would source the various config files and set the $PS1 (prompt) and $PATH, restore any aliases (your ll) etc. – ivanivan Jul 30 '19 at 18:32
  • why do my other users not have this issue when i do a su? – Patoshi パトシ Jul 30 '19 at 18:34
  • 1
    It depends on how you/they configured their startup files: read 6.2 Bash Startup Files – glenn jackman Jul 30 '19 at 18:36
  • same issue actually even with su - prntscr.com/om4mt5 – Patoshi パトシ Jul 30 '19 at 18:37
  • 2
    What is the user's login shell according to getent passwd userx? – Kusalananda Jul 30 '19 at 19:04

It is very likely that you did not set a login shell for the user when you created them, causing su to default to /bin/sh. As noted in man su:

       The invoked shell is chosen from (highest priority first):

           The shell specified with --shell.

           If --preserve-environment is used, the shell specified by the
           $SHELL environment variable.

           The shell indicated in the /etc/passwd entry for the target

           /bin/sh if a shell could not be found by any above method.

Using adduser instead of useradd makes this process easier.

If there is no login shell listed next to the user in /etc/passwd, that would confirm that this is the issue.

You can fix this by running usermod -s /bin/bash <username>

| improve this answer | |
  • yes. thank you. that works! – Patoshi パトシ Jul 30 '19 at 20:18
  • userx can change it herself with chsh /bin/bash – bbaassssiiee Jul 31 '19 at 8:29

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.