How to prevent a Linux system user from logging into the system

The shell setting in /etc/passwd determines whether a Linux system user may log in via the shell or over SSH. If you don’t want a certain user to be able to log in, set the shell to /bin/false or /sbin/nologin.

For the user “otheruser” on Debian and Ubuntu Linux, here’s an example:

usermod -s /bin/false otheruser

For Redhat, Fedora or CentOS use /sbin/nologin:

Sponsored
usermod -s /sbin/nologin otheruser

Warning: Do not set the shell for the root user to /bin/false or /sbin/nologin!

The post How to prevent a Linux system user from logging into the system appeared first on FAQforge.

Sponsored


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply