Working with Users and Groups
Based on a user's ID and the groups it is a part of, Linux manages access to resources.
Commands
Print information about users who are currently logged in.
users, who, w, whoami
Users
An account is based on a user, a password, a home directory and other information, that can be seen in some of the Linux O.S. configuration text files.
/etc/passwd
user:x:1000:1000:user,,,:/home/user:/bin/bash
1st column - user name
2nd column used to be the hash of the user's password, replaced by an x
*
in the second column disable logins to the accountPassword hashes were moved to the
/etc/shadow
file
3rd column - user's UID (User's Unique Identifier)
4th column - user's primary group ID - GID
both UIDs are used for file permissions and process managing
5th column - additional text information, each info separated by a comma
,
- GECOS6th column - user's home directory
7th (last) column - user's default login shell
/usr/sbin/nologin
and/bin/false
are used to prevent interactive shell logon with that user
Normal user accounts start with UID 1000
📌 /etc/passwd explained.
📌 /etc/shadow explained.
Groups
/etc/group
user:x:1000:
1st column - group name. Primary group of the user is the unique group associated only with that user.
2nd column - group password, not used, replaced by an x
3rd column - group's unique identifier - GID
4th last column - comma separated list of group members
adm (administrator level privileges) and sudo (run commands as any user/group) groups are very important groups with high level privileges.
📌 List groups explained.
Last updated