> For the complete documentation index, see [llms.txt](https://devops-3.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devops-3.gitbook.io/devops/docs/linux-cheat-sheet/user-management.md).

# User Management

| Command                                                          | Description                                | Example                                                   |
| ---------------------------------------------------------------- | ------------------------------------------ | --------------------------------------------------------- |
| <mark style="color:red;">**whoami**</mark>                       | Display the current logged-in username.    | whoami → Outputs the current user's username.             |
| <mark style="color:red;">**who**</mark>                          | Show logged-in users and their activities. | who → Lists all logged-in users with session details.     |
| <mark style="color:red;">**adduser \[name]**</mark>              | Add a new user to the system.              | sudo adduser john → Creates a new user john.              |
| <mark style="color:red;">**passwd \[user]**</mark>               | Change the password for a user.            | sudo passwd john → Changes john's password.               |
| <mark style="color:red;">**usermod -aG \[group] \[user]**</mark> | Add an existing user to a group.           | sudo usermod -aG sudo john → Adds john to the sudo group. |
| <mark style="color:red;">**id \[user]**</mark>                   | Display user and group ID information.     | id john → Displays the UID and GID of john.               |
| <mark style="color:red;">**deluser \[name]**</mark>              | Remove a user from the system.             | sudo deluser john → Deletes the user john.                |
| <mark style="color:red;">**groups \[user]**</mark>               | Show the groups a user belongs to.         | groups john → Displays the groups that john is a part of. |
