LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-14-2009, 11:10 AM   #1
green_dood
Member
 
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Blog Entries: 1

Rep: Reputation: 15
Smile Bash processing tips needed for listing passwordless users.


Hi there guys:

I was asked to list passwordless or locked accounts in a fedora system. As far as I know, fedora or RH dont allow passwordless accounts (the system locks the account Edit: ... unless you set passwd -d :-P ), so I might show info about locked accounts.


I am totally aware that I could do a grep or an awk searching for "!!" or "", but my people is asking me to check against passwd -S (which prints info of accounts). The thing, is that in Solaris you can check with passwd -a -s all the users, but in Linux I couldnt find anything similar.

The question here is what approach do you reccomend for passing, say , the list of users ( like the output of awk searching only user names) to the command passwd -S one by one?

Any comments?

Thanks for your support!

Last edited by green_dood; 05-14-2009 at 11:17 AM.
 
Old 05-14-2009, 11:19 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
a 'man passwd' gave me:

# passwd -aS

Oups, hit enter a bit too quick...

a = all,

You should be able to work it out from there

Last edited by eco; 05-14-2009 at 11:20 AM.
 
Old 05-14-2009, 12:03 PM   #3
green_dood
Member
 
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Question

Quote:
Originally Posted by eco View Post
a 'man passwd' gave me:

# passwd -aS

Oups, hit enter a bit too quick...

a = all,

You should be able to work it out from there
[root@satellite ~]# passwd -aS
passwd: bad argument -aS: unknown option


Sorry, tried it before (I even used passwd -a -S ). Which version of fedora are you using? Mine is Fedora 11
 
Old 05-14-2009, 04:54 PM   #4
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
I am running Kubuntu with the password binary version 4.1.1

Code:
$ dpkg -l|grep passwd
ii  base-passwd                                3.5.21                                   Debian base system master password and group
ii  kdepasswd                                  4:4.2.2-0ubuntu4                         password changer for KDE 4
ii  passwd                                     1:4.1.1-6ubuntu6                         change and administer password and group dat
what does the man page say? Maybe you have an older version but I'm sure you could loop through the passwd file and check them individually with the 'passwd -S' command
 
Old 05-15-2009, 12:13 PM   #5
green_dood
Member
 
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Smile Solved :-)

Yep, I needed to run a little script to first get all the users and then pass them to passwd -s

Code:
USERS="$(cut -d: -f 1 /etc/passwd)"
for u in $USERS
do
passwd -S $u | grep -Ew "NP" > /dev/null
if [ $? -eq 0 ]; then
myUID=`awk -F":" "/$u/"'{ print $3}' /etc/group`
myGroups=`awk -F":" "/$myUID/"'{ print $1}' /etc/group`
echo Username: $u , UID: $myUID, GROUPS: $myGroups >>$reportFile
fi
done
 
  


Reply

Tags
awk, bash, passwd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux for Word-processing/Music Playing only? How fast will it boot? Tips? Romanus81 Linux From Scratch 3 11-01-2008 05:03 AM
Bash time of day processing keith.brown Programming 1 05-18-2007 08:06 PM
bash string processing powah Programming 3 03-14-2007 06:40 AM
processing command args in bash slzckboy Programming 10 09-28-2005 04:49 PM
Svc needed for speech processing Stephanie Linux - General 1 08-05-2003 09:27 AM


All times are GMT -5. The time now is 05:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration