Hi I need to create some local users but then 'disable' that user. I know i can enable and disable the user by using usermod -L and -U but does anyone know if there is a way for me to see the current status of the user? ie locked or unlocked? thanks
On Tue, Oct 28, 2008 at 7:46 PM, Tom Brown <tom at ng23.net> wrote:> Hi > > I need to create some local users but then 'disable' that user. I know i can > enable and disable the user by using usermod -L and -U but does anyone know > if there is a way for me to see the current status of the user? ie locked or > unlocked?Can use: passwd -S username It will give either: username PS 2008-10-28 0 9999 7 -1 (Password set, MD5 Crypt) or when locked: username LK 2008-10-28 0 9999 7 -1 (Password locked) I'm sure there's other way.
On Oct 28, 2008, at 7:46 AM, Tom Brown wrote:> I need to create some local users but then 'disable' that user. I > know i can enable and disable the user by using usermod -L and -U > but does anyone know if there is a way for me to see the current > status of the user? ie locked or unlocked?this should get you a list of all the users which have been disabled by means of `usermod -L`: perl -e 'open($SHADOW, "<", "/etc/shadow") or die( "$!\n" ); while ( < $SHADOW> ) { chomp; print "$1\n" if (/^([^:]*):!{1}[^!:]*:.*$/) } close( $SHADOW );' you'll need to run it as root. no doubt that regex could be cleaned up a bit :) -steve --- If this were played upon a stage now, I could condemn it as an improbable fiction. - Fabian, Twelfth Night, III,v -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2209 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20081028/4f4be09c/attachment-0003.p7s>
> > > this should get you a list of all the users which have been disabled > by means of `usermod -L`: > > perl -e 'open($SHADOW, "<", "/etc/shadow") or die( "$!\n" ); while ( > <$SHADOW> ) { chomp; print "$1\n" if (/^([^:]*):!{1}[^!:]*:.*$/) } > close( $SHADOW );' > > you'll need to run it as root. no doubt that regex could be cleaned > up a bit :)thanks both - that gives me something to work with
On Tue, 28 Oct 2008, Tom Brown wrote:> I need to create some local users but then 'disable' that user. I know i can > enable and disable the user by using usermod -L and -U but does anyone know > if there is a way for me to see the current status of the user? ie locked or > unlocked?[herrold at mailhub ~]$ sudo passwd -l archive Locking password for user archive. passwd: Success [herrold at mailhub ~]$ sudo passwd -S archive archive LK 2008-07-15 0 99999 7 -1 (Password locked.) [herrold at mailhub ~]$ see also: man chage -- Russ herrold