How To: List All Users In Linux

If you want to list all users in Linux, this is the article for you. It should be a fairly short article, but it should tell you how to list all users. So, there’s that. By that, I mean it’ll probably do what it says on the tin, namely telling you how to list all your users.

You may want to check the list of users from time to time. Applications may add users, you may have added users, malicious software or people may have added users, etc… There are other reasons to list all users, but you get the idea.

This is a beginner-level exercise, so you shouldn’t have any difficulty with it. It should also be reasonably short, which is nice! If you find any mistakes or have any questions, scroll down and leave a comment. You can also ask on the lovely Linux.org forums.

Without further ado…

List All Users:

Once again, we start with opening the terminal. To do this, you just press CTRL + ALT + T and the terminal should open. That’s true on most distros that I’ve encountered. If not, you will still need an open terminal.

Got it open? Good, ’cause it’s a pretty easy operation. The file you’re looking for is ‘/etc/passwd’, which is a plain text file that’s in conjunction with the /etc/shadow file. Like most text files, it’s easy enough to work with them in the terminal.

You probably shouldn’t edit /etc/passwd by hand, but we’re just going to be viewing it.

So, to show the content of the file (and see the list of users):

If you want to show fewer results at a time, you can just use:

If you want, you can ‘grep’ a specific user. Just pipe the output to grep and you’re good to go. It looks like this:

If you want to use that format AND have numbered lines, one way of finding out how many users there are, then just use:

Though you could just as easily have used this to get the number:

If you want to list just the users, you can use ‘awk’ and pick the first column like this:

And that’s about it, really. You’ve now listed all the users – and counted ’em!

Closure:

That’s it! That’s all there is to it, and you’ve learned a little bit more – this time how to list users in Linux. I told you that it’d be pretty painless and easy. Plus, this is another article for the books – and this one authored early enough to give me some time to keep scheduling them ahead of time.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.