How To List All Users and Groups in Linux

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

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 User File Named passwd

Print User File Named passwd

As we can see each line of the output provides the user name, user id, user group, user shell, user home path etc.

Print Only Usernames

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

Print Only Usernames

Print Only Usernames

Print Users Who Have Login

By default normal users will login to the Linux box. But in some cases service users do not need to login Linux system. This is also a security measure. We can list users who do not have login right with the following command. This login information is stored in the /etc/passwd file.

Print Users Who Have Login

Print Users Who Have Login

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 Users Who Have Home Directories

Print Users Who Have Home Directories

Print Group File

Linux users have primary and secondary groups. These group names are stored in the /etc/group file. We can print this group information and assigned user with cat command. For more details read following tutorial.

LEARN MORE  Linux SSH Server (sshd) Configuration and Security Options With Examples

How To Add User To A Group In Linux

Print Group File

Print Group File

Print Only Group Names

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

Print Only Group Names

Print Only Group Names

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Leave a Reply

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

Enjoy this blog? Please spread the word :)