When Linux users use sudo, it shows that xxx is not in the sudoers file. This incident will be reported. The solution

1. Switch to the root user, needless to say how to switch, if you don’t know how to do it, go to Baidu.

2. Add the write permission of the sudo file, the command is:
chmod u+w /etc/sudoers

3. Edit the sudoers file
vi /etc/sudoers
to find this line root ALL=(ALL) ALL, add xxx ALL=(ALL) ALL under him (where xxx is your username)

ps: Here you can sudoers add any one of the following four lines
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL

The first line: allow the user youuser to execute the sudo command (password required). The
second line: allow users in the user group youuser to execute the sudo command (need to enter the password). The
third line: allow the user youuser to execute the sudo command, and execute Do not enter the password.
The fourth line: Allow users in the user group youuser to execute the sudo command, and do not enter the password when executing.

4. Revoke the sudoers file write permission, command:
chmod uw /etc/sudoers

This way normal users can use sudo.

Supplement:
Note that under the Ubuntu system, the Unix operating system does not create a password for root, you need to use sudo passwd root to configure a password for the root user, and then you can log in.

Guess you like

Origin blog.csdn.net/qq_29111047/article/details/131884105