0

I am new to Linux and I am using Centos7 from AWS and I am slightly confused. To my understanding, in order to use sudo, you need to be in sudoers and by default, the root user and group wheel are in sudoers. I am currently the centos user and I can use sudo, but I can't understand why. I don't believe I am in the group wheel. My sudoer file

And using cat /etc/group, I don't see centos in the group wheel

4
  • 3
    Please don't post images of text. Commented Aug 8, 2022 at 21:34
  • Also, post (text) example of how you're successfully using sudo ? Commented Aug 8, 2022 at 21:43
  • Also check /etc/sudoers.d for any included files. Commented Aug 8, 2022 at 21:49
  • I've no idea what those images show, other than it seems to be screenshots of text. Please replace them with the actual test so that the information is readable Commented Aug 8, 2022 at 22:14

1 Answer 1

3

In cloud environments, many distributions (including CentOS 7) use cloud-init to configure the system when it first boots.

If we look at /etc/cloud/cloud.cfg on the CentOS 7 cloud image, we find:

system_info: default_user: name: centos lock_passwd: true gecos: Cloud User groups: [wheel, adm, systemd-journal] sudo: ["ALL=(ALL) NOPASSWD:ALL"] shell: /bin/bash distro: rhel paths: cloud_dir: /var/lib/cloud templates_dir: /etc/cloud/templates ssh_svcname: sshd 

This says, "create a user named centos and apply the sudo configuration ALL=(ALL) NOPASSWD:ALL to that user. This causes cloud-init to create the file /etc/sudoers.d/90-cloud-init-users with the content:

# Created by cloud-init v. 18.2 on Mon, 08 Aug 2022 22:07:23 +0000 # User rules for centos centos ALL=(ALL) NOPASSWD:ALL 

And that is why the centos user has sudo access.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.