Linux for Developers Course
Linux for Developers
/
Intermediate

usermod

Definition

User Modify. A command used to modify the properties of an existing user account, such as changing their login name, home directory, or group memberships.

Explain Like I'm New

Updating an employee's badge. You use this to promote someone into a new team (group) or change their username.

Real World Example

You need to give Bob administrative `sudo` privileges. You type `sudo usermod -aG sudo bob`. This appends Bob to the 'sudo' group, granting him admin rights.

Common Use Cases

  • •Managing permissions
  • •Locking/Unlocking accounts

Interview Questions

basic

  • What does the `-L` flag do in `usermod -L bob`?

intermediate

  • Why MUST you use the `-a` (append) flag when adding a user to a new group with `-G`?

Flash Cards

Question

What is -L?

Click to reveal answer
Answer

Lock. It instantly locks the user's password, preventing them from logging in, without deleting their account.

Question

Why use -aG?

Click to reveal answer
Answer

If you use `-G` without `-a`, Linux will remove the user from ALL their current groups and only put them in the new one, heavily breaking their permissions.