Báo lỗi is not in the sudoers file anywhere

Both the above answers are correct as far as they go but it is easier to add your user to the sudo group in debian based systems (Ubuntu, kbuntu, debian, etc) and the wheel group under RedHat based systems (RedHat, Fedora, CentOS, etc)

usermod -a -G sudo user
or
usermod -a -G wheel user 

answered Dec 14, 2017 at 10:13

8

This is a very common error for the beginners. The error occurs because we are trying to access/update something with super privileges from the user instead of root -user.

Hence, to solve this,we need to make changes in the sudoers file where the root user has been given the privileges. So, switch to root user,run the following command

sudo su 
# vi /etc/sudoers

The editor would open the file, now scroll down to the bottom where you will see a line


# User privilege specification
root     ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL

As you can see, I have just added my username with all permissions.

Save the file, and exit. Switch back to the user and start using sudo commands with ease.

answered Jul 20, 2019 at 12:12

Sonal Sonal

5895 silver badges7 bronze badges

3

At the top of the aforementioned

user_name ALL=(ALL)  ALL

6 file there's an info:

"## This file MUST be edited with the 'visudo' command as root."

In order of doing as we're told, use:

$ su
Enter root password: * $ visudo -f /etc/sudoers

Find the following section of

user_name ALL=(ALL)  ALL

6 file and add your users privileges:

# User privilege specification
root    ALL=(ALL:ALL) ALL
user_name ALL=(ALL) ALL

Save the file (press esc and type

user_name ALL=(ALL)  ALL

8 if vim is your default text editor, for nano press ctrl+o, enter and then ctrl+x).

Type

user_name ALL=(ALL)  ALL

9 to turn off the

usermod -a -G sudo user
or
usermod -a -G wheel user 

0 shell, and enjoy the power of

usermod -a -G sudo user
or
usermod -a -G wheel user 

1 with your

usermod -a -G sudo user
or
usermod -a -G wheel user 

2

answered Dec 9, 2019 at 20:06

wscourgewscourge

10.9k14 gold badges59 silver badges81 bronze badges

Got a slightly different syntax to Rodney's from my host

usermod -aG wheel username

Their explanation was

The user will need to be added to the wheel group. Use the usermod command to add the user to the wheel group.

You may need to log off and log back in after doing this

answered Jul 5, 2018 at 15:41

Báo lỗi is not in the sudoers file anywhere

Robert SinclairRobert Sinclair

4,6712 gold badges44 silver badges46 bronze badges

3

You should use

usermod -a -G sudo user
or
usermod -a -G wheel user 

3 to edit /etc/sudoers file.

Just run

usermod -a -G sudo user
or
usermod -a -G wheel user 

4

and add your username with correct syntax and access rights. You can find more in

usermod -a -G sudo user
or
usermod -a -G wheel user 

5

snowpeak

80710 silver badges26 bronze badges

answered Dec 14, 2017 at 9:39

  1. Entered Root using command

    usermod -a -G sudo user or usermod -a -G wheel user

    6. Input Root Password
  2. Install sudo:

    usermod -a -G sudo user or usermod -a -G wheel user

    7
  3. Add your < username>

    usermod -a -G sudo user or usermod -a -G wheel user

    8
  4. usermod -a -G sudo user or usermod -a -G wheel user

    9
  5. Then sign up and sign in the < username> session
  6. Finally, check with:

    sudo su

    vi /etc/sudoers

    0

answered Jun 13, 2019 at 19:20

Báo lỗi is not in the sudoers file anywhere

Braian CoronelBraian Coronel

22.2k4 gold badges58 silver badges62 bronze badges

1

If you're unable to find visudo on your system

whereis visudo

Launch this tool

user_name ALL=(ALL)  ALL

0

add this line under

User privilege specification

user_name ALL=(ALL)  ALL

Save the changes and here you go !

answered May 11, 2020 at 12:19

Báo lỗi is not in the sudoers file anywhere

Olivier D'AnconaOlivier D'Ancona

8012 gold badges15 silver badges30 bronze badges

First, switch/ log into the root user account or an account that has sudo privileges.

Next add the user to the group for sudo users:

  • If you're on Ubuntu members of the sudo group are granted with sudo privileges, so you can use this:

    user_name ALL=(ALL) ALL

    2
  • If you're on CentOS members of the wheel group are granted with sudo privileges, so you can use this::

    usermod -aG wheel username

Note: Replace username with your desired

usermod -a -G sudo user
or
usermod -a -G wheel user 

2.

To test the sudo access, log into the account that you just added to the sudo users grouP, and then run the command below using

usermod -a -G sudo user
or
usermod -a -G wheel user 

1:

user_name ALL=(ALL)  ALL

4

You will be prompted to enter the password. If the user have sudo access, the output will be:

user_name ALL=(ALL)  ALL

5

If you get an error saying user is not in the sudoers file, it means that the user doesn’t have sudo privileges yet.

That's all.

I hope this helps

answered Sep 18, 2020 at 14:34

Báo lỗi is not in the sudoers file anywhere

Promise PrestonPromise Preston

25.2k13 gold badges149 silver badges150 bronze badges

try this video, it works for me.

  1. ssh root@localhost
  2. sudo vi /etc/sudoers
  3. insert username in file 'sudoers'
  4. save and exit ssh

Báo lỗi is not in the sudoers file anywhere

Dharman♦

31.3k25 gold badges88 silver badges134 bronze badges

answered Dec 30, 2020 at 3:35

Add your user to the list of sudoers. This will make it easier to execute commands as the user that you have created will require admin privileges.