I tried to disable login for a user account but got this error in debain:
useradd: unrecognized option '--disabled-login'
What is the equivalent of this command for useradd? Do I have to pick another shell, if so, which one?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Pay special attention to the use of
adduser and which distro you're on. The implementations are often different across distros. I usually use
For example, you can just lock the password:
$ sudo passwd -l <username>
$ sudo passwd -u <username>
I'd also direct you to these Q&A's that already cover the various methods for "locking" a user's account.
useradd's man page:
--disabled-login Do not run passwd to set the password. The user won't be able to use her account until the password is set.
If the user already exists, consider using usermod. You have more than 1 way to disable login. One is just to not set a password (* or x or anything invalid in /etc/passwd). The other is to set default shell of a user to /bin/false (some distros define /bin/NoShell, /bin/nologin or something).
usermod -s /bin/false -p x <username>