mohit sharma
mohit sharma

Reputation: 650

Unable to access dotnet via sudo dotnet in CentOS

I'm using CentOS headless server on azure, & I set up .Net core there. I'm able to access dotnet --info but unable to access sudo dotnet --info. Provided, I cant access root user.

Upvotes: 1

Views: 1013

Answers (1)

mohit sharma
mohit sharma

Reputation: 650

Looking deeper into sudo here, I found out that, When running sudo, many systems are configured to clear the environment of all non-whitelisted values, and to reset the PATH variable to a sanitized value.

This was actually clearing out the PATH for dotnet, restricting the command to not be executed with sudo. For the solution, You will find Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin in /etc/sudoers. Removing that line from sudoers file will resolve that issue.

You can access sudoers file by visudo command.

Upvotes: 3

Related Questions