Add users to sudoers in CentOS

Source: Internet
Author: User

Add users to sudoers in CentOS

Environment: VMware12, CentOS7

Background: After Entering terminal, the default value is normal. Previously, you can use the Ubutu series to directly increase user permissions. However, in CentOS, the following message is displayed: the user is not in the sudoers file, therefore, you must add the user to the sudoers file.

Operation:

1. First enter root

Command: su root

2. You can then directly modify the permissions of the/etc/sudoers file.

Command: chmod 777/etc/sudoers

Ls-l/etc/sudoers

3. Use vim to edit the/etc/sudoers file.

Command: vim/etc/sudoers

4. Find the line of "root ALL = (ALL) ALL" in the file and add a line below: [your username/username] ALL = (ALL) ALL

Note: 1. It seems that it cannot be edited at the beginning. Press a to enter the editing status.

2. Here I use spaces to separate fields. The editing is to use the tab key.

3. Press esc to exit the editing status after editing.

5. Enter the wq command to save and exit.

Note: 1. There is a colon

2. If the exit fails, enter wq! Command to force exit

6. Restore the access permission of/etc/sudoers

Command: chmod 440/etc/sudoers

7. switch back to normal user

Command: su [user name/username]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.