Linux allows multiple users with their own custom setting and configuration to work together on the same system, even at the same time. It can even allow a particular user to access several sessions from different locations in order to work on the system. Below is a list of different commands to access the list of users in Linux: 1. less command: Each local user’s information is stored in the “/etc/passwd/” file, where each line in the file represents login information for one user. less command extracts user information from that file. Syntax:
$less /etc/passwd
Example:
- Username
- Encrypted Password
- User ID number(UID)
- User group ID number(GID)
- Full name of the user(GECOS)
- user home directory and
- Login shell respectively.
2. getent command: This command fetches user information from database configured in /etc/nsswitch.conf. file which also includes passwd database. Syntax:
$getent passwd
Example:
$awk -F: '{print$1}' /etc/passwd
$cut -d: -f1 /etc/passwd
$getent passwd | awk -F: '{print$1}'
$getent passwd | cut -d: -f1
Example:
$compgen -u
Example:
$who
Example:
$getent passwd |wc -l
Example: