Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I forgot a user that I created on solaris 10, so now I would like to list all user names on my server.

Is it possible (I am root user)? What command I should use if possible?

Somewhere on the net I read getent will list all usernames of a group. I have tried getent without a group as I do not remember group also, but got error message (getent databse usage ..)

share|improve this question

migrated from stackoverflow.com Jan 26 '12 at 13:13

This question came from our site for professional and enthusiast programmers.

Show the code that you tried and the error message that you got! – ShiDoiSi Jan 25 '12 at 11:04
up vote 4 down vote accepted

getent passwd will list all known users, not only those present on the local /etc/passwd file.

share|improve this answer

Is there a reason why you cannot use the passwd database?

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

From the perspective of a group, users are usually listed as part of the group in the /etc/group database:


share|improve this answer
Unless you are on a standalone machine, the password database is not necessarily limited to the accounts stored in the /etc/passwd file. There are other common sources for user accounts, especially NIS and LDAP, the reason why getent is to be preferred. – jlliagre Jan 26 '12 at 14:48
@jlliagre - Very true. I took from the OP that getent had already been tried. Additionally my interpretation of the phrase "created on solaris 10" lead me to believe that the user was local, which may be incorrect. – Tok Jan 26 '12 at 21:15

You can use the dispuid command. From the man page:

    dispuid - displays a list of all valid user names

     dispuid displays a list of all user names on the system (one
     line per name).
share|improve this answer
awk -F':' '{ print $1 ,  $2 }' /etc/shadow | egrep -v "NP|LK"

will print accounts from shadow file that are not locked or have no password - so the rest is active accounts with passwors set - I guess that is what you are after ?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.