Add a normal user to sudoers in a Linux system

Source: Internet
Author: User

We often use the sudo command under the ordinary user, in order not to switch the root user frequently, we can add ordinary users to sudoers inside. Linux defaults to not adding users to the Sudoers list, and requires root to manually add the account to the Sudoers list for the normal account to execute the sudo command. The following actions are listed in the centOS6.9 system

One. Switch the login account to the root account

1. Click the user name in the upper-right corner and click the switch user in the drop-down list.

2. In the switch user interface, click Other

3. Enter root, then enter the password to enter the root user

Two. Add the original normal user to sudoers under root user

1. Open terminal, type Visudo

In the text that appears, type/root, looking for the line shown below

Root all= (All) all

After you find this line as shown above, hover the cursor over this line, type yy to copy, and then type P, which will be automatically pasted on the next line

2. Hover the cursor over the root of the copied line, type CW (to replace root), type the account name you want to add, such as: Eric, the result is shown below

Root all= (All) all

Eric All= (All) all

3. Free use of sudo

If you do not need to enter a password when you want to execute the sudo command later, you can type NOPASSWD before the all value of the line copied above: The result is shown below

Root all= (All) all

Eric All= (All) Nopasswd:all

4. Save exit, edit complete, press ESC on the keyboard, exit Insert mode, enter command line mode

Then type: Wq to save the exit

5. Switch back to normal user attempt to execute sudo command

Type the sudo space directly at the front of the command, such as Sudo shutdown-h now to perform an immediate shutdown command.

Note: If the user is not in the Sudoers list, you will get the following prompt.

Eric is isn't in the sudoers file. This incident would be reported.

Add a normal user to sudoers in a Linux system

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.