Skip site navigation (1)Skip section navigation (2)
Date:      Tue,  8 May 2001 16:32:02 +0100 (BST)
From:      jamie@psi-domain.co.uk
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/27205: Listing all users in the passwd file
Message-ID:  <20010508153202.9C4B5402EC6@rafiu.psi-domain.co.uk>

next in thread | raw e-mail | index | archive | help

>Number:         27205
>Category:       bin
>Synopsis:       Listing all users in the passwd file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 08 08:40:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jamie Heckford
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
Psi-Domain Limited 
>Environment:

FreeBSD storm.psi-domain.co.uk 4.2-STABLE FreeBSD 4.2-STABLE #2: Fri Mar  2 10:32:25 GMT 2001

>Description:

I was recently trying to discover a way of getting a list of all users on
one of my systems, and could not find an easy way to do it.

I discovered the following awk script that prints out all users on the system
(from /etc/passwd). (Courtesy of sendmail.org)

awk -F: '$3 > 100 { print $1 }' /etc/passwd 

Which will print out a list of all users in the passwd file wuth a UID greater
than 100.

Could this be turned into a command such as "userlist", and/or would it be
deemed usefull?

Another good feature that many people get stuck on is for sending email to
all users on the system. Maybe it could be included as part of the sendmail
distro, with something like:

awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers

and put in cron.daily.

This could then be a default in /etc/mail/aliases:

allusers:       :include:/etc/mail/allusers

What do you think? :)

Jamie
 

>How-To-Repeat:

userlist
--------

awk -F: '$3 > 100 { print $1 }' /etc/passwd

Sendmail
-------

awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers
echo "allusers:   :include:/etc/mail/allusers" >> /etc/aliases ; newaliases
echo "#\!/bin/sh" > /etc/periodic/350.allusers
echo "awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers" >> /etc/periodic/350.allusers
chmod 0755 /etc/periodic/350.allusers

>Fix:

Tested the above and worked fine, just need someone to tell me its great
or completly useless! :)

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010508153202.9C4B5402EC6>