How To List All Users and Groups in Linux


Users and group files are important for linux. Normal users will interact with linux systems by using credentials provided in the user ad group file.

Print User File Named passwd

We can get content of the user file like below.  This file provides usernames home directories and shell information.

Print Only Usernames

We can print only usernames by filtering other columns like below.

Print Users Who Have Login

We can print only users who have login right

Print Users Who Have Home Directories

We can print only users who have home directories in /home. This command will first look in to the passwd to list users how have /home and then print only user names from result.

Print Group File

We can print group file like below

Print Only Group Names

We can print only group names by cutting other column like below.

LEARN MORE  Vi/Vim Save And Quit

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)