-1

im adding one user to the sudoers file and when i enter the command sudo adduser <username> sudo, shows error <username> is not on the sudoers file. this incident will be reported.

Any suggestion what could it be? why that error if im trying to add.

PerlDuck
  • 13,335
  • @PerlDuck, sorry, I didn't notice it. Then I'll delete my comment. Thank you for notifying me. I already posted an answer, I hope it helps solving the problems – singrium Nov 23 '18 at 17:10
  • 3
    @singrium No worries. Sometimes when I see weird commands obviously missing something I just hit "edit" to check the original text for such <> parts. – PerlDuck Nov 23 '18 at 17:12
  • 1
    That's a great idea to check the original text. I'll be doing the same too. – singrium Nov 23 '18 at 17:14

2 Answers2

3

You are trying to use sudo , however you do not have the right to do so as you yourself are not a member of the sudo group. In such circumstances you will always get that error message when you attempt to use sudo for whatever reason. Example (notice that richard is not a member of sudo):

richard@s15:~$ groups
richard adm cdrom dip plugdev lxd lpadmin sambashare libvirtd
richard@s15:~$ sudo ls -l
[sudo] password for richard:
richard is not in the sudoers file.  This incident will be reported.

Now, that same thing for me (notice that I am a member of the sudo group):

doug@s15:~$ groups
doug adm cdrom sudo dip plugdev lxd lpadmin sambashare libvirtd
doug@s15:~$ sudo ls -l
total 4112
drwxrwxr-x  2 doug doug   4096 Oct 25 16:37 audio
drwxr-xr-x 39 doug doug   4096 Oct 14  2016 backup_carrie_01
...

Furthermore, since I have the rights to do so, I can add richard to the sudo group:

doug@s15:~$ sudo adduser richard sudo
Adding user `richard' to group `sudo' ...
Adding user richard to group sudo
Done.

And for a subsequent login for richard:

richard@s15:~$ groups
richard adm cdrom sudo dip plugdev lxd lpadmin sambashare libvirtd
richard@s15:~$
Doug Smythies
  • 15,448
  • 5
  • 44
  • 61
  • True. But this suggests that the OP tried to add himself to the sudo group (without being member of it), doesn't it? We dont't know whether the two "instances" of <username> in his post refer to the same or different unames. – PerlDuck Nov 23 '18 at 17:24
  • 1
    Yes. The adduser part is a red herring, in my opinion. That error message only appears when a non sudo user tries to use sudo, at least that I am aware of. That is why in my answer I used a trivial command. – Doug Smythies Nov 23 '18 at 17:26
0

Try to add the user to the sudoers file manually:

  • Go to home directory by running command cd
  • Then type sudo su

It will ask you to type your password to be in root user.

  • Run visudo
  • Then add this line to the end of the file (change username with your username:

    username        ALL=(ALL)      ALL
    
  • Save and exit

Credits:
Username is not in the sudoers file.

singrium
  • 6,880