Add a user to sudoer list
By default, users are not added to the sudoers list in Linux. You need to manually add the account to the sudoers list by the root user so that the normal account can execute the sudo command.
The root account can enter the sudo configuration by typing mongodo. This command is much better than Vim/etc/sudoers, because using mongodo for sudo configuration will receive many prompts.
After you type export do, type/root in the editor to find the root line and find the third root line.
Root all = (all) All
Press yyp to copy and paste the next line. Enter CW at the root of this line to replace root with the account name of the user you want to add. For example, in blinux, the result is:
Root all = (all) All
Blinux all = (all) All
If you do not need to enter the password when executing the sudo command, it can be shown
Root all = (all) All
Blinux all = (all) nopasswd: All
Enter: WQ to save.
Then, when executing the sudo command, enter a sudo space in the front-end of the command. For example, sudo shutdown-H now executes the immediate shutdown command.
If you need to enter a password, enter the user password instead of the root password.
Note: If the user is not in the sudoers list, the following message is displayed.
Blinux is not in the sudoers file. This incident will be reported.