User Management
Linux provides command-line tools for creating, modifying, and removing user and group accounts.
Creating and Deleting Users
To create a new local user:
useradd bobOne can add options such as -m to create a home directory or -s /bin/bash to set the default shell.
When creating the user in person (not from a script) a much better alternative is adduser. This is an interactive script that creates the user and also directly sets a password
Set the password with:
passwd bobTo delete a user:
userdel bobBy default, this keeps the user’s home directory; add -r to remove it.
User Management
See current user:
whoamiSee which users are logged in:
whoDisplay current (or other) user and group identity:
id
id bobView the last logged in users
lastGroup Management
Create a new group:
groupadd -g 1050 developers-g can also be skipped to use a generated ID
Delete a group:
groupdel developersModifying Users
Change password expiration settings:
chage bobCheck which groups a user belongs to:
groups bobAdd a user to a supplementary group:
usermod -aG sudo bob # Attach to group