Xxx is not in the sudoers file. This incident will be reported. solution, sudoersfile. this
1. Switch to the root user
The su command switches between common users and root users, and the password set during installation must be entered;
2. Add the write permission for the sudo file. The command is:
Chmod u + w/etc/sudoers
3. Edit the sudoers file
Vi/etc/sudoers
Find this line of root ALL = (ALL) ALL, add xxx ALL = (ALL) ALL under it (here xxx is your user name)
Ps: You can add any of the following four lines to sudoers:
Youuser ALL = (ALL) ALL
% Youuser ALL = (ALL) ALL
Youuser ALL = (ALL) NOPASSWD: ALL
% Youuser ALL = (ALL) NOPASSWD: ALL
Line 1: allow the user youuser to execute the sudo command (password required ).
Line 2: Allow users in the user group youuser to execute the sudo command (password required ).
Row 3: allows the user youuser to execute the sudo command without entering the password during execution.
Row 4: Allow users in the user group youuser to execute the sudo command without entering the password during execution.
4. revoke the sudoers file write permission by running the following command:
Chmod u-w/etc/sudoers
In this way, general users can use sudo.
In addition, the Red Hat version adds a line number for linux. After the above-mentioned sudo user is added
$: Sudo vi/etc/vimrc
Add: set nu at the end of the document, save and exit.