Set permission to run dnf command in sudoers file

Following is the syntax i am using to provide a group to run only dnf command using sudo without password.

%groupname All=(ALL:ALL) NOPASSWD: dnf

After closing the sudoers file , i am running into an error in the above line. Please help . Thanks

Hi @krsindhu1992,

Can you try

%groupname ALL = NOPASSWD: /bin/df

Happy learning,
Trung.

Hi @trung-kodekloud ,

Thanks, Appreciate your reply.

I tried using the above mentioned syntax : %groupname ALL = NOPASSWD: /bin/dnf . It isnt working.

And the command is dnf , not df.

1 Like

Sorry,

I thought it was disk free command df, let me try other options.

Thanks,
Trung.

Hi @krsindhu1992

You should use visudo to edit sudoers - you probably are if is telling you error immediately.

Prerequisites for this are

  1. Know the correct path for dnf
    which dnf
    
  2. Ensure the group you want to assign permissions exists.

For example, if the group is devs and dnf is at /usr/bin/dnf then it will be

%devs ALL=(ALL) NOPASSWD:/usr/bin/dnf
1 Like

Hi @Alistair_KodeKloud ,

The above solution worked . Thanks a lot.

1 Like