Managing_Users_and_Groups_in_Linux
Managing_Users_and_Groups_in_Linux
This document provides a guide on how to manage users and groups in Linux. It includes
commands to create, remove, and manage users and groups, along with their purposes.
1. Managing Users
Creating a User
To create a user, you can use the following commands:
1. Basic Command:
```bash
sudo adduser <username>
```
- Prompts for user details like password and information.
- Automatically creates a home directory for the user (e.g., /home/<username>).
Removing a User
To remove a user, you can use the following commands:
1. Remove a User:
```bash
sudo deluser <username>
```
- Removes the user but retains their home directory.
2. Managing Groups
Creating a Group
To create a group:
```bash
sudo groupadd <groupname>
```
Adding a User to a Group
To add a user to a group:
```bash
sudo usermod -aG <groupname> <username>
```
- Use the `-aG` option to append the user to the group without removing them from other
groups.
Removing a Group
To remove a group:
```bash
sudo groupdel <groupname>
```