4

In Linux distributions like RedHat you can create a user with options --disabled-login and ---disabled-password (see man page for command adduser link).

I wonder if it is possible to check for an administrator after user creation if the login and password is disabled for a given user? Exists there any possibility?

3
  • 1
    Have a look at /etc/shadow/. The second field is the password. When it starts with double exclamation mark !!, the account is locked. Run adduser with different options and explore the effect on the new user's line in the shadow file. Feb 26, 2021 at 8:54
  • in almost every case, saying something like "in Unix...", is a generalization, one that doesn't apply. E.g. FreeBSD and OpenBSD do have adduser, but it's not the same command as on Linuxen, and doesn't have those flags. Also, on Debian, adduser is a Perl script that calls useradd, on FreeBSD it's described as a shell script that uses the pw command. Actually, it's not even the same command across different Linuxes, as in CentOS, it appears to be a link to useradd...
    – ilkkachu
    Feb 26, 2021 at 14:49
  • Thank you for your comments, i have precised the query and refering to common linux distributions in the enterprise like RedHat
    – megloff
    Feb 26, 2021 at 14:52

1 Answer 1

5

This information can be gathererd using the passwd utility.

From man passwd

-S, --status

Display account status information. The status information consists of 7 fields. The first field is the user's login name. The second field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P). The third field gives the date of the last password change. The next four fields are the minimum age, maximum age, warning period, and inactivity period for the password. These ages are expressed in days.

To check the status of every user on the system, run

passwd -a -S

A disabled (locked) user might look like this:

apache L 08/30/2019 0 99999 7 -1

Note the L, indicating the account is locked.

A regular user might look like this:

panki P 09/23/2019 0 99999 7 -1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .