Number of users in passwd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Number of users in passwd
# 1  
Old 03-10-2010
Number of users in passwd

This command prints out username/users in /etc/passwd:
Code:
cut -d ':' -f '1,5' /etc/passwd | sort

I wonder if I also, after above commands output, can get an output that lists number of users in the group? I need to use uniq to get rid of duplicates.
I´ve tried this, but cant get it right, can anyone help please?

Last edited by vbe; 03-10-2010 at 06:26 AM.. Reason: code tags
# 2  
Old 03-10-2010
Try this :-
Code:
awk -F':' '{ print $3}' /etc/passwd   | sort  | uniq -c


Last edited by pludi; 03-10-2010 at 06:34 AM.. Reason: code tags, please...
# 3  
Old 03-10-2010
Ok, thank you, but I dont get the output, first 13 and then 1 and -2(?) up till 99.
Please help me to understand
Output:

[ 1 -2
1 0
1 1
1 26
1 27
1 4
1 54
1 55
1 56
1 58
1 59
1 60
1 65
1 67
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 91
1 92
1 93
1 94
1 95
1 96
1 97
1 99]
# 4  
Old 03-10-2010
I think Jairaj ,it should be $4 instead of $3.We can achieve it easily by cut command as follows.
This will give output as number of users in each group. First field is a no of users and second field is s group_id.

Code:
cut -d ':' -f 4 /etc/passwd | sort | uniq -c


Last edited by Nila; 03-10-2010 at 06:44 AM..
# 5  
Old 03-10-2010
editing my last post

Dont know why but the post was missing 13 first in the output I wrote, adn dont mind the [] just for showing the oouput start and end.
# 6  
Old 03-10-2010
4Th field is the group id

Code:
awk -F':' '{ print $4}' /etc/passwd |sort -nr | uniq -c

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Can't change users passwd

Have an issue with a user or root changing the user's passwd. We run the passwd command and a complex passwd is entered a message is displayed, "passwd is based on a dictionary word." We do have a dictionary file and I know for a fact the complex passwd is not in the list. This happens on a... (3 Replies)
Discussion started by: solizkewl
3 Replies

2. Solaris

Impact on existing users when changing passwd defaults

Hi Administering Solaris Systems - Solaris 10 mostly. If I change the /etc/default/passwd settings - E.G. to increase minimum passwd length, then what happens to existing users with passwords shorter than this. presumably they are not affected until next time they want to change password. ... (4 Replies)
Discussion started by: Mudshark
4 Replies

3. Shell Programming and Scripting

Removing old user directories that are no longer Users in /etc/passwd

I am new to shell scripting, and have not done much programming in several years. So I am very rusty at this at best. I know my way around the linux command line, but actually scripting is something I have not done too much of. I have been tasked to come up with a script that will pull all... (5 Replies)
Discussion started by: shuiend
5 Replies

4. Shell Programming and Scripting

Number of users problem

Hi. I have a problem with my homework. I have to do a Script that will tell me the number of users that are logged in on my system through a network and find out their IP's. Can you give me an idea? Thanks (1 Reply)
Discussion started by: mitzu
1 Replies

5. Shell Programming and Scripting

number of users logged in script

My admin needs a shell script in Korn that will show conditions based on users logged in. I have never used the Korn shell and have no clue what I am doing, can anyone help. here are the conditions that need to be returned. if users are below 5 displays should be: performance is high if... (1 Reply)
Discussion started by: vthokiefan
1 Replies

6. Solaris

Defaults number of users and Groups

Hi All, I would like know how many of default number of users and groups are there in solaris-10... Regards Tirupathi Raju (2 Replies)
Discussion started by: tirupathiraju_t
2 Replies

7. Shell Programming and Scripting

to find the number of users logged in

Hi, can u say to display the number of users that logged before me. thanks (10 Replies)
Discussion started by: shanshine
10 Replies

8. UNIX for Dummies Questions & Answers

editing sqlplus id@passwd in multiple scripts, users and directories

hi all, i was given by my supervisor a task to search for scripts which contain oracle sqlplus i.e "myusername/mypasswd @myDB" in every /home/userfolder, which are, all the scripts made by different user. I've done some find command to search string for sqlplus, but it may up too long to respond.... (8 Replies)
Discussion started by: Helmi
8 Replies

9. Shell Programming and Scripting

append 3 users in /etc/passwd

I am looking to add 3 lines in /etc/passwd via a script. Can you please give me an idea on how to write a script that can do that? (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

10. UNIX for Dummies Questions & Answers

Maximum number of users allowed

How do i determen (what command) the max. number of users allowed Thanks in advance (10 Replies)
Discussion started by: siza
10 Replies
Login or Register to Ask a Question