Sponsored Content
Full Discussion: Counting total users
Top Forums UNIX for Dummies Questions & Answers Counting total users Post 302412870 by Scott on Tuesday 13th of April 2010 07:40:08 PM
Old 04-13-2010
You're welcome. But note that not all users in the passwd file are really "people". i.e. on my Mac there are 65 entries in the passwd file, and there's only me and root (also me) in the vicinity Smilie

Special "users" like daemon, nobody, lpr, etc. are used by the system for various functions.

If you have any convention by which user ID's are assigned, you may want to count only those that match.

i.e. assuming that "real" user IDs start from 1000:

Code:
awk -F: '$3 >= 1000 { C++ } END { print C+0 }' /etc/passwd

(or shorter, with wc)
Code:
awk -F: '$3 >= 1000' passwd | wc -l


Last edited by Scott; 04-13-2010 at 08:58 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep running total/ final total across multiple files

Ok, another fun hiccup in my UNIX learning curve. I am trying to count the number of occurrences of an IP address across multiple files named example.hits. I can extract the number of occurrences from the files individually but when you use grep -c with multiple files you get the output similar to... (5 Replies)
Discussion started by: MrAd
5 Replies

2. Shell Programming and Scripting

counting users?

Is it possible to count the number of users? or specifically emac users? I know that you can count certain file sizes, like find /usr/bin/ -size 11k -exec ls {} \;|wc -1 but how would I count users? (3 Replies)
Discussion started by: gordonheimer
3 Replies

3. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

4. Solaris

To restrict the users not to change the passwords for NIS users

Hi All, How to restrict the NIS users not to change their passwords in for NIS users?? and my NIS user is unable to login to at client location what could be the problem for this ? Any body can help me. Thanks in advance. (1 Reply)
Discussion started by: Sharath Kumar
1 Replies

5. Shell Programming and Scripting

Total number of users logged in a server from uptime

how to find out total number of users logged in a server from uptime . i mean to say i need the total output of unix command . who gives the out put at a particular time . I need at all time from which machine who has connected , (3 Replies)
Discussion started by: amiya.te@gmail
3 Replies

6. Shell Programming and Scripting

Help with sum total number of record and total number of record problem asking

Input file SFSQW 5192.56 HNRNPK 611.486 QEQW 1202.15 ASDR 568.627 QWET 6382.11 SFSQW 4386.3 HNRNPK 100 SFSQW 500 Desired output file SFSQW 10078.86 3 QWET 6382.11 1 QEQW 1202.15 1 HNRNPK 711.49 2 ASDR 568.63 1 The way I tried: (2 Replies)
Discussion started by: patrick87
2 Replies

7. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

8. Shell Programming and Scripting

To get total number of users and their groups in remote UNIX machine

Hi All I am trying to do ssh to different server and on the remote server for each user trying to get groups of that user but i am not getting the required result. ssh username@ip_address "for i in $( cat /etc/passwd| cut -d: -f1);do groups $i done;exit" >>abc.txt only names are... (5 Replies)
Discussion started by: Ekamjot
5 Replies

9. Shell Programming and Scripting

Counting total files with different file types in each folder

Trying to count total files with different file types with thousands of files in each folder. Since some files do not have extensions I have to use below criteria. Count Total Files starting with --> "^ERROR" Count Total Files starting with --> "^Runtime" Count Everything else or files... (3 Replies)
Discussion started by: kchinnam
3 Replies
QUOT(8) 						      System Manager's Manual							   QUOT(8)

NAME
quot - summarize filesystem ownership SYNOPSIS
quot [ -acfguvi ] [ filesystem... ] DESCRIPTION
quot displays the number of kilobytes in the named filesystem currently owned by each user or group. Note that this utility currently works only for XFS. OPTIONS
-a Generate a report for all mounted filesystems giving the number of kilobytes used by each user or group. -c Display three columns giving file size in kilobytes, number of files of that size, and cumulative total of kilobytes in that size or smaller file. The last row is used as an overflow bucket and is the total of all files greater than 500 kilobytes. -f Display count of kilobytes and number of files owned by each user or group. -g Report on groups. -u Report on users (the default). -v Display three columns containing the number of kilobytes not accessed in the last 30, 60, and 90 days. -i Ignore mountpoints mounted by automounter. -T Avoid truncation of user names longer than 8 characters. -q Do not sort the output. FILES
/etc/mtab mounted filesystem table /etc/passwd default set of users /etc/group default set of groups SEE ALSO
du(1), ls(1). BUGS
Currently, only the XFS filesystem type is supported. QUOT(8)
All times are GMT -4. The time now is 08:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy