Wednesday, 23 February 2022

How to Allow SUDO Access to a Domain User/Group on CentOS 8



By default, Domain users doesn’t have any type of sudo privilege and even can’t switch as root user. On CentOS 8 sudo access can be granted access based on usernames or groups and same can be done for one/many commands.

This article describes How to Allow SUDO Access to a Domain User/Group on CentOS 8

[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@linuxcnf ~]#

Step 1. Create Separate file for Granting SUDO Access: Run the below command and put content into file to allow access for a user:

[root@linuxcnf ~]# vi /etc/sudoers.d/sudo-access-ad-users
user@linuxcnf.com        ALL=(ALL)       ALL

The above line grant sudo access to user. As above can be added multiple users.
After adding, save the file and don’t forget to run the below command on every edit of sudoers file to check sudoers file syntax:

[root@linuxcnf ~]# visudo -c

Step 2. Grant SUDO for a Group: Run the below command and add the below line to provide sudo access:

[root@linuxcnf ~]# vi /etc/sudoers.d/sudo-access-ad-users
%group@linuxcnf.com     ALL=(ALL)   ALL

The above line grant sudo access to group and it will provide sudo access to all the group members. As above can be added multiple groups.

Done!!! As above SUDO access can be granted to a Domain User/Group on CentOS 8.

1 comment:

  1. Multi-domain hosting options are great for my various projects.

    ReplyDelete