Progress: 0/62 (0%)

πŸ‘₯ Adding Users to Groups

Adding Users to Groups & Giving Sudo Privileges

Think of groups as teams or departments in our office.
β€’ A group is like a team that shares access to certain rooms or resources.
β€’ A user can belong to one or more groups, like an employee being part of Marketing and Project A team.
β€’ Some users might also be given special powers, like a manager who can enter any roomβ€”this is like sudo privileges.

2a. groupadd

groupadd is like creating a new team in the company.

sudo groupadd developers

Now we have a team called developers. Anyone added to this group can access shared resources for that team.

2b. usermod

usermod is how you assign employees to teams.

sudo usermod -aG developers john
  • -aG β†’ append this group to their list (don't remove from other groups).

Real-life analogy: John is officially added to the Developers team without kicking him out of Marketing.

groups john

To check groups a user belongs to.

2c. Giving a user sudo privileges

Sudo = giving a user manager-level access.

Managers can perform any operation in the office, like modifying office-wide files.

Usually, the sudo group is pre-defined. Add a user to it:

sudo usermod -aG sudo john

Now John can use commands like:

sudo apt update

Real-life analogy: John now has the key to the main office and can approve big changes, but still logs in with his own employee ID.

Real-life analogy

βœ… Key takeaway:
1. groupadd = create a team
2. usermod -aG groupname username = add user to a team
3. sudo group = manager-level access