[Linux] Add sudo permissions to new users under Centos7

Straight to the point:

After we use adduser to create a new user, this new user does not have permission to use sudo.

For example, we create a new user fortest:

This user does not have permission to use sudo:

We can modify (/etc/sudoers) the file sudoers in this path under root to solve it.

 We can see that this file is read-only,

According to the knowledge of permissions we have learned before, it is obvious that only the root user can modify,

We enter the command:

vim /etc/sudoers

You can enter this file, (enter shift + g (run to the bottom of the file))

Basically you can find:

Through the vim knowledge we learned before, enter i to enter the insert mode,

enter:

这里是你的用户名 ALL=(ALL) ALL

Then enter the bottom line mode, enter: wq! (force write and exit) 

We found that the fortest user can use sudo.

Finally, I would like to say this principle,

In fact, adding that piece of code to the sudoers file is essentially like adding it to a trust list or white list.

Hope this article can help you.

Write at the end:

The above is the content of this article, thank you for reading.

If you feel that you have gained something, you can give the blogger a like .

If there are omissions or mistakes in the content of the article, please private message the blogger or point it out in the comment area~

Guess you like

Origin blog.csdn.net/Locky136/article/details/131022002