0% found this document useful (0 votes)
7 views

Managing_Users_and_Groups_in_Linux

fuefuewhfuhewufhewu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Managing_Users_and_Groups_in_Linux

fuefuewhfuhewufhewu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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>).

2. Add a User Without a Home Directory:


```bash
sudo useradd <username>
```
- Use this if you don't need a home directory for the user.

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. Remove a User with Home Directory:


```bash
sudo deluser --remove-home <username>
```

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 User from a Group


To remove a user from a group:
```bash
sudo gpasswd -d <username> <groupname>
```

Removing a Group
To remove a group:
```bash
sudo groupdel <groupname>
```

3. Viewing Users and Groups

List All Users


To list all users on the system:
```bash
cat /etc/passwd
```

List All Groups


To list all groups on the system:
```bash
cat /etc/group
```

View Groups for a Specific User


To view the groups a specific user belongs to:
```bash
groups <username>
```

You might also like