Managing Users and Groups
Concept
Linux is a multi-user operating system. Every process and file has an owner (user) and a group.
Key Commands
bash
# Create a user
useradd -m -s /bin/bash agent-admin
# Set a password
passwd agent-admin
# Create a group
groupadd agent-common
# Add a user to a group
usermod -aG agent-common agent-admin
# Check user info
id agent-admin
# Example output: uid=1001(agent-admin) gid=1001(agent-admin) groups=1001(agent-admin),1002(agent-common),1003(agent-core)Related Files
| File | Contents |
|---|---|
/etc/passwd | List of users |
/etc/group | List of groups and their members |
/etc/shadow | Encrypted passwords |
Why Split Accounts by Role
If you do everything with a single root account, one mistake can affect the entire system. Splitting accounts by role limits the scope of permissions and keeps the impact of failures to a minimum.
Summary
- Every process and file has an owner (user) and a group.
- Create and check accounts and groups with
useradd/passwd/groupadd/usermod -aG/id. - Account information is stored in
/etc/passwd,/etc/group, and/etc/shadow. - Splitting accounts by role limits the scope of permissions and keeps the impact of failures to a minimum.
Source: Codyssey-B1/B4-1
