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
Ubuntu Server Admin

Recent Posts

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

7 hours ago

Revolutionizing Web Page Creation: How Structured Content is Slashing Design and Development Time

Co-authored with Julie Muzina A year ago, during our Madrid Engineering Sprint, we challenged ourselves…

1 day ago

Ubuntu Weekly Newsletter Issue 897

Welcome to the Ubuntu Weekly Newsletter, Issue 897 for the week of June 15 –…

2 days ago

Ubuntu Core is now available on MediaTek’s Genio platform

This is the first optimized Ubuntu Core image available on MediaTek’s Genio 350, 510, 700,…

2 days ago

Effective infrastructure automation to reduce data center costs

Data centers are expensive: automation is the solution Today, managing a data center requires striking…

5 days ago

What are our partners building for device makers? Explore the highlights from Ubuntu IoT Day Singapore

Our first Ubuntu IoT Day in Southeast Asia – and our first ever event in…

6 days ago