Linux: 'Username' is not in the sudoers file. This incident will be reported

前端 未结 10 1908
南方客
南方客 2020-12-05 12:05

After logging into ssh, I got this message:

\'Username\' is not in the sudoers file. This incident will be reported.

How can I r

相关标签:
10条回答
  • 2020-12-05 12:25

    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 
    
    0 讨论(0)
  • 2020-12-05 12:28

    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

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

    0 讨论(0)
  • 2020-12-05 12:29

    Open file

    sudo nano /etc/sudoers
    

    Then add the user below admin user like below syntax.

    user_name ALL=(ALL)  ALL
    
    0 讨论(0)
  • 2020-12-05 12:30

    You should use visudo to edit /etc/sudoers file.

    Just run sudo visudo -f /etc/sudoers

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

    0 讨论(0)
提交回复
热议问题