Linux 001 and linux 001
Problem 1:Xxx is not in the sudoers file. This incident will be reported.
1. Switch to the root user. You don't need to switch to the root user.
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.