When running the sudo command on Linux, the following error is reported: xxx is not in the sudoers file. This incident will be reported.
This problem occurs because the user executing the sudo command is not in the sudoers file list. You can solve this problem by editing the sudoers file.
There are two ways to edit the sudoers file: one is to execute vi sudo with the root account, and the other is to execute vi/etc/sudoers with the root account. In fact, both are to modify/etc/sudoers.
Assume that your user name is "tuzhu" and belongs to the "tuzhu" user group.
To enable user tuzhu to execute sudo, you can add any row of four rows in the sudoers file.
Tuzhu ALL = (ALL) ALL % tuzhu ALL = (ALL) ALL tuzhu ALL = (ALL) NOPASSWD: ALL (this setting is recommended for convenience) % tuzhu ALL = (ALL) NOPASSWD: ALL
Note:
Line 1: allow the user tuzhu to execute the sudo command (password required ).
Line 2: Allow users in the tuzhu user group to execute the sudo command (password required ).
Line 3: allow the user tuzhui to execute the sudo command without entering the password during execution.
Row 4: Allow users in the tuzhu user group to execute the sudo command without entering the password during execution.
Of course, if you understand the above principle, you can directly enter the following command to solve this problem
Su-echo 'xxx ALL = (ALL) all'>/etc/sudoers (xxx indicates the user name)