LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 03-02-2012, 04:01 AM   #1
zama
Member
 
Registered: Mar 2012
Posts: 34

Rep: Reputation: Disabled
Identifying usernames having duplicate user-id in /etc/passwd file


Hi All,

I am trying to find out all users in my /etc/passwd which has duplicate user-ids . e.g if there are two users having user-id of 0. It should display the username as well as the user-id. I tried the following:

awk -F: '{
count[$3]++;}END {
for (i in count)
print i, count[i];
}' passwd

It gives the duplicate user-ids and how many times they are occuring . I actually want the usernames to be displayed along with the duplicate user-ids similar like

zama 0
root 0
bin 100
nologin 100

Will be great if the solution is provided with awk asscociative arrays. Other methods are also fine.

Thanks in Advance
 
Old 03-02-2012, 06:10 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Code:
awk -F: '
{
    count[$3]++;
    name[$3] = name[$3] $1 " "
}
END {
    for (i in count)
        print i, count[i], name[i];
}' /etc/passwd
 
  


Reply



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
System usernames versus user numbers -- incompatibility? eater Linux - Software 4 03-01-2008 10:53 AM
identifying ip address of http user in postfix carlosuribe Linux - Security 1 04-29-2005 06:49 AM
530 Must perform authentication before identifying USER. talk2me Linux - Networking 1 11-08-2004 04:51 AM
using gftp I need to perform authentication before identifying USER. pcpinkerton Linux - Security 3 04-18-2004 08:30 AM
SAMBA - Windows user aliases to linux usernames? Bungo2000 Linux - Software 4 06-27-2003 04:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:34 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration