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
  • Also, post (text) example of how you're successfully using sudo ?
    – steve
    Aug 8, 2022 at 21:43
  • Also check /etc/sudoers.d for any included files.
    – user516667
    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
    – roaima
    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.

Not the answer you're looking for? Browse other questions tagged .