LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can I use /sbin/nologin to prevent a user to have access to interactive shell? (https://www.linuxquestions.org/questions/linux-newbie-8/can-i-use-sbin-nologin-to-prevent-a-user-to-have-access-to-interactive-shell-4175442436/)

jeffersonmvg 12-21-2012 06:59 AM

Can I use /sbin/nologin to prevent a user to have access to interactive shell?
 
Can I use /sbin/nologin to prevent a user to have access to interactive shell?

Thanks in advance

Ser Olmy 12-21-2012 07:59 AM

According to man nologin, that's the entire purpose of the program. To prevent logins, that is.

shivaa 12-21-2012 08:06 AM

You can create /etc/nologin to restrict users from login into the system. Only root login will be allowed then.

--- Adding -------

Hi @jeffersonmvg,
Perhaps I didn't read your question properly & I thought you want to restrict users from login into system.
Anyway, you can use /sbin/nologin shell to restrict user, but check whether this is available in your system or not.
If it's not available, then you can add /bin/false as shell for the user whom you do not wish to give login access.
Code:

usermod -s /sbin/nologin username
OR
usermod -s /bin/false username

In addition to /bin/false, add /dev/null in place of home directory in /etc/passwd. (Note: Take backup of /etc/passwd if you manually edit it). New /etc/passwd file entry for that user will look like this:
Code:

username:x:123:123:Sample:/dev/null:/bin/false

jeffersonmvg 01-02-2013 04:37 AM

Thank you shivaa :D


All times are GMT -5. The time now is 09:52 AM.