当我执行sudo命令时,显示:
xxx is not in the sudoers file. This incident will be reported.
我想要用root用户去修改配置文件,当我输入su -时,显示:
su: Authentication failure
感觉进入了一种死循环,不知从何下手。
...全文
1663打赏收藏
关于用户权限的小疑问
当我执行sudo命令时,显示: xxx is not in the sudoers file. This incident will be reported. 我想要用root用户去修改配置文件,当我输入su -时,显示: su: Authentication failure 感觉进入了一种死循环,不知从何下手。
随便搜到的,没有验证过
How to fix “username is not in the sudoers file. This incident will be reported” Error In Ubuntu
Reboot the computer. If Ubuntu is your primary and the only operating system in your computer, press the “Shift” button when it is booting up. This should make the Grub screen show up on your monitor. On the Grub screen, press the down button to the Recovery mode and press Enter.
On the next screen, select “Check all file system (will exit read only mode)”.
When you see the message “Finished, press Enter“, press Enter.
Next, select “Drop to root shell prompt”.
You will now be at the command line. Type:
usermod -a -G root sysadmin
Replace the username with your own login name.
That’s it. Now type “exit” and select “Resume normal boot”.
到这里问题应该就已经解决了。下面的步骤好像是应急措施
Follow the Steps below if u messup With sudoers file
Do the Steps Untill 3
sudo cp /etc/sudoers /etc/sudoers.backup
sudo nano /etc/sudoers
Check the following lines in the file
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Next save the file using
# wq!
Net Change the permission to the sudoers file
# chmod 440 /etc/sudoers
Then Add your Username to the Sudo group
usermod -a -G root sysadmin
Exit the Shell and resume normal boot are restart ...