Add users to sudoers in CentOS

Source: Internet
Author: User

Add users to sudoers in CentOS
In Ubuntu, General Accounts can execute commands as super users through the sudo command, as long as they enter the user's password. However, in CentOS, that is, when you create a user to install the system, the user has the Advance setting item. You can add the newly created user to the group. If this parameter is set to sudoer/sudoers, after logging on to the system and executing the sudo command, the system still prompts that the user does not exist in the sudoers group. In this case, we need to add the current user to the sudoers user group. 1. modify the permissions of the/etc/sudoers file 1. Because the owner of the/etc/sudoers file is root, the current permission of this file is

      -r--r-----.  1 root root  #440
  • 1
2. to modify this file, you need to change its permissions to write permissions for other users, or switch to the superuser mode.
Switch User: directly switch to the root mode, and directly modify the file or modify the permissions: After modifying the permissions of the root identity, access with the current user identity.
  • 1
  • 2
  • 3
2. Add a user to sudoers. 1. Find the user in the sudoers file.
Root ALL = (ALL) ALL # Next line feed and add the current user to xxx ALL = (ALL) ALL;
  • 1
  • 2
2. If you do not want to enter the password every time, you do not need to enter the password every time after modification.
  xxx ALL=(ALL)  NOPASSWD: ALL
3. revoke the permission on the/etc/sudoers file. If you modify the permission of the file to add users, You need to restore the permission attribute of the file after the file is added. 4. NOTE: If chmod 777/etc/sudoers is directly used for graph convenience during permission modification, the permission must be restored after the user is added, if the sudo command is not executed, the following error message is displayed:
  sudo:/etc/sudoers is world writable  sudo:no valid sudoers sources found ,quitting  sudo:unable to initialize policy plugin
  • 1
  • 2
  • 3

Run the following command to fix the problem:

Run chmod 440/etc/sudoers as root.

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.