Blame

1d4d54 J4nis05 2024-05-30 15:47:33 1
Here's a short guide on how to add a user to the sudoers file and grant them full administrative permissions on a Debian system:
2
3
1. **Add the user to the sudo group**:
4
Assuming the username is `username`, add the user to the `sudo` group. This group has sudo privileges by default.
5
```bash
6
sudo usermod -aG sudo username
7
```
8
9
2. **Verify the user is added to the sudo group**:
10
Check the group membership of the user to ensure they have been added to the `sudo` group.
11
```bash
12
groups username
13
```
14
15
3. **Edit the sudoers file (optional)**:
16
If you need to provide specific permissions or want to manually add the user to the sudoers file, use the `visudo` command to safely edit the file:
17
```bash
18
sudo visudo
19
```
20
21
4. **Add user with full sudo permissions**:
22
Within the `visudo` file, add the following line to grant full sudo permissions to the user `username`:
23
```bash
24
username ALL=(ALL:ALL) ALL
25
```
26
27
5. **Save and exit**:
28
If using the default editor (`nano`), save the file by pressing `Ctrl+O`, then press `Enter` to confirm. Exit the editor by pressing `Ctrl+X`.
29
30
6. **Test the sudo access**:
31
Switch to the user and test if they have sudo privileges:
32
```bash
33
su - username
34
sudo ls /root
35
```
36
37
The command should prompt for the user's password and then list the contents of the `/root` directory if the user has proper sudo access.
38
39
That's it! The user `username` should now have full administrative permissions using `sudo`.