CentOS adds users to the sudoer list
CentOS adds users to the sudoer list
CentOS
By default, linux does not include the current user in the sudoer list (most common in the redhat series linux release). If you use sudo to execute some commands, the system will prompt you that the user is no longer in the sudoer list. At this time, we need to manually add.
1. Type $ su in the command line, enter the password of the root account, and switch to the root account. $ is the command prompt, which does not need to be typed.
2. Type # cmddo in the command line to open the sudo configuration file.
In linux, any configuration file is saved as a text file, that is, you can use vim to open the sudo configuration file, but it is not recommended to do so, because mongodo is a tool provided by linux to modify the sudo configuration file, compared with vim, it provides more prompt information and Error Correction capabilities.
3. Like editing a text file with vim, we search for the root keyword, So enter/root in the open file.
4. Press the n key on the keyboard to automatically jump to the next root keyword, always jump to this sentence:
# Allow root to run any commands anywhere
Root ALL = (ALL) ALL
Press the n key, and the cursor will appear on the root of root ALL = (ALL) ALL.
5. Enter yyp and press Enter. These are the two commands in vim. Yy indicates copying the current line, and p indicates pasting the copied content to the next line. Therefore, after entering this command, the original text is changed to the following:
# Allow root to run any commands anywhere
Root ALL = (ALL) ALL
Root ALL = (ALL) ALL
6. press the j key, the cursor will jump to the second root ALL = (ALL) ALL line, then press the number 0 Key, let the cursor back to the beginning of the line, then press 4 x key, delete the four root letters in the row. Press the I key to enter the insert mode and enter your user name. For example, if my current user name is xin, I enter xin. After the input, the original text is changed to the following:
# Allow root to run any commands anywhere
Root ALL = (ALL) ALL
Xin ALL = (ALL) ALL
7. Press the ESC key (in the upper left corner of the keyboard, on the left side of F1) and press: wq to exit and save the current configuration file.
8. Now the modification is complete. The user xin has been added to the sudoer list. You can use the user xin to execute the sudo command.