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

不羁岁月 提交于 2019-11-26 21:41:14

问题


After logging into ssh, I got this message:

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

How can I resolve this? I'm connecting ssh to my virtual private server.


回答1:


Open file

sudo nano /etc/sudoers

Then add the user below admin user like below syntax.

user_name ALL=(ALL)  ALL



回答2:


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 



回答3:


You should use visudo to edit /etc/sudoers file. Just run visudo -f /etc/sudoers and add your username with correct syntax and access rights. You can find more in man sudoers




回答4:


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.




回答5:


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.




回答6:


  1. Entered Root using command $ su root. Input Root Password

  2. Install sudo: $ apt-get install sudo -y

  3. Add your < username> $ adduser <username> sudo

  4. $ exit

  5. Then sign up and sign in the < username> session

  6. Finally, check with: < username>@< hostname>:~$ sudo apt-get update



来源:https://stackoverflow.com/questions/47806576/username-is-not-in-the-sudoers-file-this-incident-will-be-reported

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!