Managing Users & Groups
Managing Users
In Linux, user properties encompass various attributes and settings associated with a user account. These properties define the user's identity, permissions, and environment within the system. Here are the key user properties you can manage:
Username
Password
UserID (UID)
GroupID (GID)
Comment
Additional information
Commonly used for full name
Home directory (~)
Default shell
User Data Files
Data is stored in /etc/passwd.
Commonly there is x where the password is.
Password hashes are stored in /etc/shadow.
User Management
useradd $options $username
Options: • -p, --pasword ◦ NOT RECOMMENDED • -u, --uid • -g, --gid • -s, --shell • -d, --home-dir • -c, --comment If option isn’t specified the defaults are used
userdel $usernameusermod $options $usernameOptions: • -l, --login ◦ Change username • -p, --pasword ◦ NOT RECOMMENDED • -u, --uid • -g, --gid • -s, --shell • -d, --home-dir • -c, --comment If option isn’t specified then it is unchanged
passwd $userChanges user password interactively. Recommended
View user information
id $usernameView all user details from /etc/passwd
getent passwd $usernameView password expiration details
sudo chage -l $usernameManaging Groups
In Linux, group properties define the characteristics and settings associated with a group. Groups are used to manage sets of users and control their permissions and access rights. Here are the key properties of group:
Group name
Password
Generally not used
GroupID (GID)
Members
Group Data Files
Stored in /etc/group
Group Management
groupadd $options $groupnameOptions: • -g, --gid • -p, --password If option isn’t specified the defaults are used
groupdel $groupnamegroupmod $options $groupnameOptions: • -n, --new-name • -g, --gid • -p, --password If option isn’t specified then it is unchanged
Users Group
To edit a user's group, witch is defaultyly built with the user, just add -G flag to useradd/usermod commands
You can use -aG flag to add group to a user.
Last updated

