List of users from command line

Brad De Vries devriesbj
Mon Jan 3 16:23:36 PST 2005


On Mon, 03 Jan 2005 14:11:34 -0500, Matthew Carpenter <matt at eisgr.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Bunch o' show-offs  :)
> 
> Brad De Vries wrote:
> | On Mon, 3 Jan 2005 11:30:55 -0500, David Bandel
> <david.bandel at gmail.com> wrote:
> |
> |>On Mon, 03 Jan 2005 10:20:15 -0500, Matthew Carpenter <matt at eisgr.com>
> wrote:
> |>
> |>>-----BEGIN PGP SIGNED MESSAGE-----
> |>>Hash: SHA1
> |>>
> |>># getent passwd
> |>
> |>if you only want user accounts, and they're all between 500-999:
> |>getent passwd | cut -f1,3 -d: - | grep [5-9].. - | cut -f1 -d: -
> |>add -v to the grep to get system accounts
> |>
> |>likewise, if your user accounts are 1000+ use:
> |>getent passwd | cut -f1,3 -d: - | grep [1-9]... - | cut -f1 -d: -
> |>
> |>The above can be refined even more, but that should give you the idea.
> |>
> |>There are similar tricks to get lists of those with null passwords, etc.
> |>
> |>
> |>>This should work for virtually any form of authentication you use.  This
> |>>has been tested and proven with compat, LDAP and Winbind
> |>>Chong Yu Meng wrote:
> |>>| Hi All,
> |>>|
> |>>| Another elementary question for the gurus on this list :
> |>>|
> |>>| I need to get a list of user accounts on a server, and though I know I
> |>>| can probably do it using webmin or graphical tools, I am specifically
> |>>| looking for a command that will do this for me. Can someone help?
> |>>|
> |>>| Thanks in Advance !
> |>
> |>Ciao,
> |>
> |>David A. Bandel
> |
> | Or, if you like awk, you could use:
> | getent passwd | awk -F: '{if (($3 >= 500) && ($3 <= 999)) {print $1}}'
> |
> | This will provide the user name only.  If you'd like to see the real
> | name as well (with a tab separator,) change the print command to
> | {print $1,"\t",$5}
> |
> | Brad.
> 
> - --
> Matthew Carpenter
> matt at eisgr.com                          http://www.eisgr.com/

I don't know about showing off but it does feel good to be able to
answer a question every now and then.  :-)


More information about the Linux-users mailing list