Linux Ask a question: How to solve "XXX is not in the sudoers file" error

Source: Internet
Author: User

question : I want to use sudo on my Linux system to run some privileged commands, but when I try to do this, I get the "[my username] is isn't in the sudoers file. This incident would be reported. " Error message. What should I do with this sudo error?

sudo is a privilege that allows specific groups of users to run a command with the privileges of another user (typically root). Sudo has detailed logging capabilities and provides fine-grained control over which commands the user can run with sudo.

Sudo vs. Su

The SU command also provides the same elevation of privilege, unlike the granularity of their authentication process and the change in privilege. SU allows you to switch from your login session to another user's session, and then you can run any program with the user's privileges, but you need to know the target user's password to switch the user. sudo, on the other hand, can work on a single command, allowing you to run individual commands with the privileges of root. With sudo you do not have to know the root password, but enter your password when prompted to enter the sudo password.

Adding users to the Sudoers list

As a new user you will encounter the following error if you try to run the sudo command. It means you're not in this list of sudoers that contains a user group that has been certified to use sudo privileges.

    1. [My-user-id] is isn't in the sudoers file. This incident would be reported.

There are two ways to add you to the Sudoers list.

Method One

The first method is to add you to the Linux user group named sudo. This particular Linux user group is preconfigured to use sudo. So once you're inside this group, you can run the sudo command.

The following command will add you to the sudo group in Linux and you will need to run the command under the root user.

    1. # AddUser < username > sudo

Now to confirm that your membership has been updated, use the groups command to see the list of groups you currently belong to. This list must contain the sudo group.

    1. $ Groups
    1. Alice ADM cdrom sudo dip plugdev fuse lpadmin netdev sambashare davfs2 libvirtd Docker promiscuous

Changes to the membership (and sudo access) will take effect after you log out and re-login.

Method Two

The second way to get you to use sudo is to add yourself directly to the/etc/sudoers configuration file.

To modify the/etc/sudoers file, you can use a special sudo editor command called Visudo. Simply invoke the following command as root.

    1. # Visudo

This command can open and edit the/etc/sudoers file, add the following line of text to the end of the file, and press ctrl+x. When the prompt appears, save the changes to exit.

    1. <username> all= (All) all

This change will take effect immediately and you'll be able to use sudo right away.

Linux Ask a question: How to solve "XXX is not in the sudoers file" error

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.