0

I created a user (useradd -d /home/newuser -c "My new user" -s /bin/true newuser), set a password (su newuser), and want to work under this username. But I cannot switch to this user. No error messages, no warnings -- the switch just does not succeed:

olduser@mymachine$ su - newuser
Password:
olduser@mymachine$ whoami
olduser@mymachine$ olduser

or

olduser@mymachine$ su newuser
Password:
olduser@mymachine$ whoami
olduser@mymachine$ olduser

How to switch the user on the CLI in SUSE Linux Enterprise Server 12?

1
  • Those are not an transcript of what happened. Please don't edit (except to obvoscate user/machine names). Commented Jan 6, 2020 at 18:44

1 Answer 1

3

I assume it is the way you created newuser assigning it a /bin/true shell by specifying -s /bin/true.

From the useradd man page:

https://linux.die.net/man/8/useradd

-s, --shell SHELL
    The name of the user's login shell. The default is to leave this field blank, which causes the system to select the default login shell specified by the SHELL variable in /etc/default/useradd, or an empty string by default. 

As you set it to /bin/true the exit status is 0 and therefore not producing any error message. Setting such shell is only common for users which should not be allowed to login to the system. Typically /bin/false is used, as this would lead to an error message similar to cannot create shell which at least gives an idea what fails.

It can be resolved by usermod -s /bin/bash newuser.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .