hoder.org

June 24, 2008

List All Unix Users

Filed under: freebsd — admin @ 12:03 pm

List All Unix Users

To list all users on a Unix system, even the ones who are not logged in, look at the /etc/password file.


$ cat /etc/passwd
...
george:*:1009:1009:George Washington:/home/george:/usr/bin/bash
tom:*:1016:1016:Thomas Jefferson:/home/tom:/usr/bin/bash
al:*:1017:1017:Alexander Hamilton:/home/alex:/usr/bin/bash
...

You can use the `cut` command to only see one field from the password file.

For example, to just see the Unix user names, use the command “$ cat /etc/passwd | cut -d: -f1″.


$ cat /etc/passwd | cut -d: -f1
...
george
tom
al
...

Or, to only see the GECOS field (i.e. the account holders real name), try this:


$ cat /etc/passwd | cut -d: -f5
...
George Washinton
Thomas Jefferson
Alexander Hamilton
...

Note that you will also see Unix system accounts, such as “root

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by hoder.org