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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-14-2009, 11:10 AM
|
#1
|
|
Member
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Rep:
|
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.
|
|
|
|
05-14-2009, 11:19 AM
|
#2
|
|
Member
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412
Rep:
|
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.
|
|
|
|
05-14-2009, 12:03 PM
|
#3
|
|
Member
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Original Poster
Rep:
|
Quote:
Originally Posted by eco
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
|
|
|
|
05-14-2009, 04:54 PM
|
#4
|
|
Member
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412
Rep:
|
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
|
|
|
|
05-15-2009, 12:13 PM
|
#5
|
|
Member
Registered: Nov 2007
Location: Puebla, Mexico
Distribution: Ubuntu, DSL, Fedora
Posts: 45
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:58 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|