Solve the following error in CentOS: xx is not in the sudoers file.

Source: Internet
Author: User

Solve the following error in CentOS: xx is not in the sudoers file.

I am using redhat5.4. If a general user executes the sudo command, the following error occurs: llhtiger is not in the sudoers file. This incident will be reported. solution:

I. $ whereis sudoers ------- locate the file location. The default value is/etc/sudoers.
Ii. # chmod u + w/etc/sudoersLog on to su-root as a Super User. Modify the File Permission to add the write permission limit for the file. ls-al/etc/sudoers can view the permissions of the original file.
3. Edit the vim/etc/sudoers file and add xxx all = (ALL) ALL and XXX as your username under the root ALL = (ALL) ALL line. Add method: Find the root line and press the "I" key to enter edit mode! After editing, the esc key enters the general mode and ": wq" is saved and exited!
Finally, # chmod u-w/etc/sudoers returns to the original permission of the file!

The following is a little more detailed:

Because the root user is disabled in ubuntu, the user created during system installation is added to sudoers by default. However, in redhat and centos, users other than root users are not added to sudoers by default. In This way, when executing the sudo command, an error such as xxx is not in the sudoers file. This incident will be reported. will appear. For the sake of security, we advocate the use of common users for daily operations, and the use of sudo when super users are needed. In this way, we need to add some users to sudoers.
In fact, it is very easy to add users to sudoers.
First, use the whereis command to find the directory of the sudoers configuration file (in/etc/sudoers by default)
[Root @ localhost xiaofei] # whereis sudoers
Sudoers:/etc/sudoers. bak/usr/share/man/man5/sudoers.5.gz
Switch to the root user and change the/etc/sudoers permission.
[Root @ localhost xiaofei] # chmod u + w/etc/sudoers
Then you can use the vi editor to add users to sudoers.
[Root @ localhost xiaofei] # vi/etc/sudoers
Then find root ALL = (ALL) The location where ALL is located. Add the user to the file,

By the way, let's take a look at the vi editor usage. When entering the vi editor, you can move the cursor by using the direction key. Find the position to be edited, press "I", and then enter the insert mode, in this case, you can enter or delete characters. After editing, press "esc" to exit the insert mode and enter the command line mode. Press ":" to enter the last line mode, and enter "wq" to save and exit.

The following is the added result.
# Allow root to run any commands anywhere
Root ALL = (ALL) ALL
Xiaofei ALL = (ALL) ALL (This line is added, and xiaofei is my user name)
Then remove the write permission of sudoers (otherwise, the suoders file cannot be executed ):
[Root @ localhost xiaofei] # chmod u-w/etc/sudoers
Now, after exiting the root user, you can use the sudo command to execute super user permissions.
Original post address: http://blog.sina.com.cn/s/blog_4ef045ab0100j59t.html

Related Article

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.