How To: List All Users In Linux

Rate this post

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.

Related Post:

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.

Images: How To: List All Users In Linux 300x300

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):

Shell

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

Shell

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:

Shell

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

Shell

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

Shell

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

Shell

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.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x