How to Install .net core in Linux

Posted by

To install .NET Core on Linux, you can follow these general steps:

  1. Update the Package Manager: Open a terminal and update the package manager to ensure you have the latest package information. The package manager’s name may vary depending on your Linux distribution. Here are a few examples:
  • For Ubuntu or Debian:
    sudo apt-get update
  • For CentOS or Fedora:
    sudo dnf update
  1. Install the Prerequisites: .NET Core has a few prerequisites that need to be installed on the system. These include the OpenSSL library, which is often required for secure connections. Install the prerequisites using the package manager:
  • For Ubuntu or Debian:
    sudo apt-get install libssl-dev
  • For CentOS or Fedora:
    sudo dnf install openssl-devel
  1. Download the .NET Core SDK: Visit the official .NET website (https://dotnet.microsoft.com/download) and download the .NET Core SDK for Linux. Choose the appropriate version for your Linux distribution and system architecture (x64, ARM, etc.). You can refer to this post to download .NET core using command line : How to download .net core package using the command line in Linux
  2. Install the .NET Core SDK: Once the download is complete, open a terminal and navigate to the directory where the downloaded SDK file is located. Run the installation command using sudo to install it system-wide. Replace <sdk-version> with the actual version number of the SDK file you downloaded.
   sudo ./dotnet-sdk-<sdk-version>-linux-x64.tar.gz
  1. Add .NET Core to the System PATH: To make the dotnet command available globally, you need to add it to the system’s PATH variable. This ensures you can run .NET Core applications from any directory. Open a terminal and run the following command:
   echo 'export PATH="$PATH:$HOME/.dotnet"' >> ~/.bashrc
   source ~/.bashrc
  1. Verify the Installation: After installation, verify that .NET Core is properly installed by opening a new terminal window and running the following command:
   dotnet --version

If the installation was successful, the command will display the version number of the .NET Core SDK installed on your system.

That’s it! You have now installed .NET Core on your Linux machine. You can start building and running .NET Core applications. Remember to consult the official documentation for any distribution-specific instructions or troubleshooting steps.