2

I feel a little silly having to ask this, but: In Solaris you can issue a passwd -sa command which gives you (more or less) the same output as passwd -S userName does, except it prints out the status information for all users it finds in /etc/passwd. What is the equivalent GNU/Linux command?

I'm trying to put together simple instructions for someone else to baseline a server, and part of that is them identifying the password aging configured on all accounts. I can for loop over cut -f1 -d: /etc/passwd but I was hoping there was a simple command I could give him.

2
  • 1
    The cut method seems reasonable and safe to me. Commented May 14, 2013 at 18:15
  • there's always chage -l <user>, looping through the /etc/passwd 8-). Commented May 14, 2013 at 18:38

2 Answers 2

2

In RHEL/CentOS there is no -a option with passwd but -S option is there. So you run this one liner as root user:

  for user in `awk -F: '{print $1}' /etc/passwd`; do passwd -S $user; done

or

  for user in $(awk -F: '{print $1}' /etc/passwd); do passwd -S $user; done
0
1

At least in shadow-utils 4.1.5.1 on Arch Linux, I have -a, which also prints the status. passwd -Sa appears to do what you want. From man passwd:

   -a, --all
       This option can be used only with -S and causes show status for all users.
   -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.
# passwd -Sa
root P 05/07/2013 -1 -1 -1 -1
bin P 09/19/2010 -1 -1 -1 -1
daemon P 09/19/2010 -1 -1 -1 -1
mail P 09/19/2010 -1 -1 -1 -1
ftp P 09/19/2010 -1 -1 -1 -1
http P 09/19/2010 -1 -1 -1 -1
uuidd P 09/19/2010 -1 -1 -1 -1
dbus P 09/19/2010 -1 -1 -1 -1
nobody P 09/19/2010 -1 -1 -1 -1
git L 05/07/2013 -1 -1 -1 -1
chris P 05/07/2013 0 99999 7 -1
avahi L 05/07/2013 -1 -1 -1 -1
mpd L 05/07/2013 -1 -1 -1 -1
ntp L 05/07/2013 0 99999 7 -1
nullmail L 05/13/2013 -1 -1 -1 -1
polkitd L 05/14/2013 0 99999 7 -1
4
  • :\ Well it looks like RHEL uses a different software package for the passwd command (passwd-0.77-4.el6_2.2.x86_64) and the shadow-utils that is included (shadow-utils-4.1.4.2-13.el6.x86_6) doesn't have a passwd command. Commented May 14, 2013 at 16:54
  • @JoelDavis could be a permissions/path issue, can you run passwd -Sa as root? Commented May 14, 2013 at 16:56
  • Sorry, I guess my response was a bit ambiguous, the -a option isn't available with the version of passwd I'm using Commented May 14, 2013 at 17:05
  • None of the versions of RH distros I have (Fedora or CentOS 5&6) have a -a switch. Commented May 14, 2013 at 18:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.