Install and Use .NET Core 6 on Amazon Linux 2

Posted on 178 views

The installation of .NET Core 6.0 on Amazon Linux 2 is covered in this post. .NET is a developer platform that includes programming languages, tools, and libraries to assist developers create a variety of applications. The ASP.NET frameworks add tools and libraries to the .NET developer platform, making it easier to create web applications. The most recent version of .NET Core is 6.0, which is an LTS version.

On Windows, Linux, and macOS, the .NET 6.0 LTS editions are available to download. The .NET Runtime and ASP.NET Core Runtime are both included in this bundle. For IIS users, there is an ASP.NET Core Module that may be installed independently from the .NET Runtime on servers.

Features of .NET Core

The following are the features of .NET Core:

  • It is a completely free and open-source framework. That is, it is free and its source code is open source.
  • It’s cross-platform, meaning it works on Windows, Linux, and Mac.
  • In .Net core application unit testing is very easy.
  • .Net Core is based on .NET Core, which allows programs to run in several versions at the same time.
  • It provides a single unified component for all platforms, such as the .NET Standard library, with the same code, languages, and tools.
  • For communication between the browser and the server, .Net core does not rely on system.web.dll. Everything we require for our application is packaged in .Net core. Packages boost application performance by reducing the request pipeline.
  • It’s a very light framework. It enables developers to distribute libraries and components as a collection of packages.
  • Dependency Injection is built-in to the framework.
  • .Net Core is an acronym for “Network Core.”
  • The .Net Core application can be hosted on a variety of Web servers, including IIS, Apache, Docker, and others. It does not rely on IIS.

What’s New in .NET Core 6 LTS

The .NET unification strategy, which began with .NET 5, is completed with .NET 6. For mobile, desktop, IoT, and cloud apps, .NET 6 unifies the SDK, base libraries, and runtime. In addition to this uniformity, the .NET 6 ecosystem includes the following features:

  • Hot Reload allows you to see code changes without having to restart the app.
  • Support for Open Telemetry and Dotnet Monitor.
  • Visual Basic in Visual Studio and Windows from project experience have been improved.
  • The ability to use JavaScript to render Blazor components.
  • AOT compilation for Blazor WebAssembly apps in WebAssembly.
  • Support for HTTP/3.
  • Fie IO now supports symbolic links.
  • OpenSSL, the ChaCha20Poly1305 encryption scheme, and defense-in-depth mitigations at runtime are all supported.
  • Source generators and analyzers are two types of source generators.
  • Across the board, performance has significantly improved.

Install .NET Core 6 LTS on Amazon Linux 2

There are Three methods to install .NET Core 6 on Amazon Linux 2:

  1. Install using binary packages
  2. Install using Snap
  3. Install using Script

Method 1: Install .NET Core using Binary packages

Execute the following command to add the Microsoft package signing key to your list of trusted keys and add the Microsoft package repository before installing .NET Core 6:

sudo rpm -Uvh

Install the .NET SDK 6 on Amazon Linux 2

The .NET SDK enables you to create .NET applications. You don’t need to install the relevant runtime if you install the .NET SDK. Execute the following command to install the.NET SDK:

$ sudo yum install dotnet-sdk-6.0
Dependencies Resolved

 Package                                                   Arch                              Version                              Repository                                              Size
 dotnet-sdk-6.0                                            x86_64                            6.0.101-1                            packages-microsoft-com-prod                            114 M
Installing for dependencies:
 aspnetcore-runtime-6.0                                    x86_64                            6.0.1-1                              packages-microsoft-com-prod                            8.7 M
 aspnetcore-targeting-pack-6.0                             x86_64                            6.0.0-1                              packages-microsoft-com-prod                            2.0 M
 dotnet-apphost-pack-6.0                                   x86_64                            6.0.1-1                              packages-microsoft-com-prod                            4.7 M
 dotnet-host                                               x86_64                            6.0.1-1                              packages-microsoft-com-prod                             67 k
 dotnet-hostfxr-6.0                                        x86_64                            6.0.1-1                              packages-microsoft-com-prod                            173 k
 dotnet-runtime-6.0                                        x86_64                            6.0.1-1                              packages-microsoft-com-prod                             29 M
 dotnet-runtime-deps-6.0                                   x86_64                            6.0.1-1                              packages-microsoft-com-prod                            3.9 k
 dotnet-targeting-pack-6.0                                 x86_64                            6.0.1-1                              packages-microsoft-com-prod                            3.1 M
 netstandard-targeting-pack-2.1                            x86_64                            2.1.0-1                              packages-microsoft-com-prod                            2.1 M

Transaction Summary
Install  1 Package (+9 Dependent packages)

Total download size: 164 M
Installed size: 459 M
Is this ok [y/d/N]: y

Install the .NET Core 6 runtime on Amazon Linux 2

The ASP.NET Core Runtime, which is the most compliant runtime for .NET, is installed with the following command. Enter the following command in your terminal:

sudo yum install aspnetcore-runtime-6.0

The .NET Runtime, which does not have ASP.NET Core functionality, can be installed as follows:

sudo yum install dotnet-runtime-6.0

Method 2: Install .NET Core using Snap on Amazon Linux 2

Snap package can also be used to install the .NET SDK or .NET Runtime. Snaps are an excellent alternative to your Linux distribution’s built-in package management.

Install the .NET SDK 6

To install a.NET SDK snap package, use the snap install command. To specify which version to install, use the –channel argument.

sudo snap install dotnet-sdk --classic --channel=6.0

Then, using the snap alias command, register the dotnet command for the system:

sudo snap alias dotnet-sdk.dotnet dotnet

Install the .NET Core 6 runtime

To install a.NET Runtime snap package, use the snap install command:

sudo snap install dotnet-runtime-60 --classic

Now, using the snap alias command, register the dotnet command for the system:

sudo snap alias dotnet-runtime-60.dotnet dotnet

Method 3: Install .NET Core using Script

The dotnet-install scripts are used for non-admin and automated SDK and Runtime installations.

First, Install the downloader wget or curl:

sudo yum install wget curl -y

Download the installer script:

#Using wget

#Using curl
curl -sLO

Make the script executable:

chmod +x

The .NET SDK 6.0 can be installed with the command below.

$ ./ -c 6.0
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit to get the installer.

dotnet-install: Downloading primary link
dotnet-install: Extracting zip from
dotnet-install: Adding to current process PATH: `/home/vagrant/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.

-c,–channel: Download from the chosen channel i.e 6.0 ; LTS is the default.

By default, the script installs the most recent SDK long-term support (LTS) version, which is .NET 6. Use the -c Current argument to install the current release.

./ -c Current

Use the –runtime parameter to install the .NET Runtime instead of the SDK:

./ -c Current --runtime aspnetcore

Add .NET binaries directory to your PATH

~/.dotnet/ should be added to your PATH environment variable:

echo 'export PATH=$PATH:~/.dotnet/' | tee -a ~/.bashrc

Run source ~/.bashrc file for it to take effect:

source  ~/.bashrc

Verify that it works:

$ echo $PATH

Check .NET Version:

$ dotnet --version

Enable TAB completion for the .NET CLI

Typing a dotnet command in the shell and then pressing the TAB key will bring up tab completion for the .NET CLI.

i) Bash

Add the following code to your .bashrc file to enable tab completion in your bash shell for the .NET CLI:

$ vim ~/.bashrc
# bash parameter completion for the dotnet CLI


  local word=$COMP_WORDS[COMP_CWORD]

  local completions
  completions="$(dotnet complete --position "$COMP_POINT" "$COMP_LINE" 2>/dev/null)"
  if [ $? -ne 0 ]; then

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )

complete -f -F _dotnet_bash_complete dotnet

ii) Zsh

Add the following code to your .zshrc file to enable tab completion in your zsh shell for the .NET CLI:

$ vim ~/.zshrc
# zsh parameter completion for the dotnet CLI


  local completions=("$(dotnet complete "$words")")

  reply=( "$(ps:\n:)completions" )

compctl -K _dotnet_zsh_complete dotnet

.NET Core 6 Usage Example

Create a hello world experiment:

$ dotnet new console -o helloworld

Welcome to .NET 6.0!
SDK Version: 6.0.101

The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry:

Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS:
Write your first app:
Find out what's new:
Explore documentation:
Report issues and find source on GitHub:
Use 'dotnet --help' to see available commands or visit:
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/vagrant/helloworld/helloworld.csproj...
  Determining projects to restore...
  Restored /home/vagrant/helloworld/helloworld.csproj (in 117 ms).
Restore succeeded.

Run the above experiment:

$ cd helloworld
$ dotnet run
Hello, World!


Our tutorial on how to install and use .NET Core 6 on Amazon Linux 2 is now complete. The .NET Framework is a cross-platform developer framework designed to aid you in the development of your apps. C#, F#, and Visual Basic are all programming languages that can be used to create .NET applications. We hope you found this tutorial to be helpful.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.