The recommended approach uses Ubuntu's own repositories (Canonical packages), since Microsoft no longer publishes separate packages for Ubuntu 24.04+.
sudo apt update
sudo apt install -y dotnet-sdk-8.0
sudo apt install -y dotnet-sdk-9.0
sudo apt install -y dotnet-sdk-10.0
Most people start with .NET 8 or .NET 9 — pick the one that matches your project.
dotnet --version
dotnet --info
You should see version information (e.g. 8.0.4xx or 9.0.xxx).
If you want the very newest .NET (preview or just-released versions) without waiting for Canonical:
sudo snap install dotnet --classic
Then check version:
dotnet --version
(The snap is maintained by Microsoft and usually contains the latest stable release.)
Use Microsoft's install script (one-line, no repo configuration needed):
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 9.0 # or 10.0, 8.0, etc.
After running, add it to PATH (if not done automatically):
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$HOME/.dotnet
Add those two lines to ~/.bashrc or ~/.zshrc for permanence.