Shell – Switch from Root to User with Nologin Shell

nologinshellusers

I'm just learning linux. Working as root, I created a new user called testuser. I then changed testuser to a nologin shell.

Now I want to login as the testuser to see what a user with a nologin shell can/can't do.

I tried: su testuser and got: This account is currently not available.
I tried: su – testuser and got:
su: warning: cannot change directory to /home/testuser: No such file or directory
This account is currently not available.

How do I switch from root to a user with a nologin shell?

Best Answer

The point of the nologin shell is to prevent the user from logging in. Such a user may still use your server services like FTP, IMAP/POP3 and others but they won't be able to login e.g. using sshd or console, period.

How do I switch from root to a user with a nologin shell?

sudo -u USERNAME /bin/bash

Will work but only root can do that.

Related Question