Issue
I want to install dotnet to root on a linux vm and be able to run the dotnet with just a
sudo dotnet
call instead of needing to give the full path every time.
I installed dotnet on a linux VM with sudo using dotnet-install.sh. Dotnet is installed in /root/.dotnet/ . I can run the dotnet executable with sudo /root/.dotnet/dotnet --version which prints the version as expected. However, even though I did export PATH='$PATH:/root/.dotnet" to add the dotnet folder to $PATH, and I can see that it's been added by doing echo $PATH, trying to execute sudo dotnet --version will result in a Command not found error. How can I add the path properly so the dotnet executable can be ran with just sudo dotnet ...?
Solution
You can try two options:
- Move the
/root/.dotnet/dotnet
binary to/usr/local/bin
, and then you should be able to execute it.
mv /root/.dotnet/dotnet /usr/local/bin
OR
- Create a symlink so that you can call the .dotnet/dotnet from your bin folder of your Linux VM:
ln -s /root/.dotnet/dotnet /usr/local/bin
Answered By - therealvirtuoso Answer Checked By - Candace Johnson (WPSolving Volunteer)