{"id":47568,"date":"2024-11-19T10:29:45","date_gmt":"2024-11-19T10:29:45","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=47568"},"modified":"2025-07-25T11:37:25","modified_gmt":"2025-07-25T11:37:25","slug":"install-net-9-or-8-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/11\/install-net-9-or-8-ubuntu\/","title":{"rendered":"How to Install .NET 9 (or 8) in Ubuntu 24.04 | 22.04 | 20.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-44743\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This tutorial shows how to install Microsoft .NET software development framework (9.0, 8.0, or even 6.0, 7.0) in current Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 LTS.<\/p>\n<p>Microsoft announced .NET 9 last week. It features over 1,000 performance related changes across the runtime, workloads, and languages. .NET Aspire 9 now has OpenAI, Ollama, Milvus integration, and preview support for Azure Functions. For other features and changes, see the <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-dotnet-9\/\" target=\"_blank\" rel=\"noopener\">announcement<\/a>.<\/p>\n<p><!--more--><\/p>\n<p>To install .NET framework in Ubuntu, there are 4 choices:<\/p>\n<ul>\n<li>native <b>.deb<\/b> package from Ubuntu system repository.<\/li>\n<li>native <b>.deb<\/b> package from Microsoft repository.<\/li>\n<li><b>Snap<\/b> package runs in sandbox.<\/li>\n<li>native <b>.deb<\/b> package from Ubuntu PPA<\/li>\n<\/ul>\n<p>According what you need, choose one of the options below.<\/p>\n<h3>Option 1: Install .NET from Ubuntu system repository<\/h3>\n<p>Ubuntu has .NET packages in system repositories. So far, they include:<\/p>\n<ul>\n<li><b>.NET 6<\/b> and <b>.NET 7<\/b> for Ubuntu 22.04.<\/li>\n<li><b>.NET 8<\/b> for Ubuntu 22.04, Ubuntu 24.04, and Ubuntu 24.10.<\/li>\n<\/ul>\n<p>To install <b>.NET 8<\/b> in 22.04 and higher, press <code>Ctrl+Alt+T<\/code> on keyboard to open terminal and run commands:<\/p>\n<pre>sudo apt update<\/pre>\n<pre>sudo apt install dotnet8<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet8.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47569\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet8-700x505.webp\" alt=\"\" width=\"610\" height=\"440\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet8-700x505.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet8-300x216.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet8.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>If you want to install .NET 7 in Ubuntu 22.04 only, use command:<\/p>\n<pre>sudo apt install dotnet7<\/pre>\n<p>And, replace number 7 in command with 6 for .NET 6.<\/p>\n<h3>Option 2: Install .NET from Microsoft repository<\/h3>\n<p>Microsoft has an official apt repository for Debian\/Ubuntu users. It contains:<\/p>\n<ul>\n<li><b>.NET 6, .NET 7, .NET 8<\/b> for Ubuntu 20.04 and Ubuntu 22.04.<\/li>\n<li><b>.NET 9<\/b> for Ubuntu 20.04 and Ubuntu 22.04 at the moment.<\/li>\n<\/ul>\n<h4>1. install the key<\/h4>\n<p>To add the Microsoft repository, you have to first download &amp; install the key file.<\/p>\n<p>To do so, press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal. When terminal opens, run single command:<\/p>\n<pre>sudo wget -O - https:\/\/packages.microsoft.com\/keys\/microsoft.asc | gpg --dearmor | sudo tee \/etc\/apt\/keyrings\/microsoft.gpg<\/pre>\n<p><i>This command will download the key, dearmor it (so it&#8217;s unreadable, see the screenshot), and save to &#8216;\/etc\/apt\/keyrings&#8217; directory.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44744\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h4>2. Add the Microsoft repository<\/h4>\n<p>Next, in terminal window, run command to create &amp; edit the sources file:<\/p>\n<pre>sudo gedit \/etc\/apt\/sources.list.d\/microsoft.sources<\/pre>\n<p><i>Depends on your desktop environment, replace <code>gedit<\/code> with <code>gnome-text-editor<\/code> for Ubuntu 24.04, <code>mousepad<\/code> for XFCE, <code>pluma<\/code> for MATE, or <code>nano<\/code> that works in most cases.<\/i><\/p>\n<p>When the file opens, add following lines and save it.<\/p>\n<pre>Types: deb\r\nURIs: https:\/\/packages.microsoft.com\/ubuntu\/<b>22.04<\/b>\/prod\/\r\nSuites: <b>jammy<\/b>\r\nComponents: main\r\nArchitectures: amd64\r\nSigned-By: \/etc\/apt\/keyrings\/microsoft.gpg<\/pre>\n<p>Here, replace <b>22.04<\/b> and <b>jammy<\/b> (they are for 22.04 and Mint 21) in the code with:<\/p>\n<ul>\n<li><b>20.04<\/b> and <b>focal<\/b> for Ubuntu 20.04.<\/li>\n<li><b>24.04<\/b> and <b>noble<\/b> for Ubuntu 24.04 and Linux Mint 22.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47570\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources-700x357.webp\" alt=\"\" width=\"610\" height=\"311\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources-700x357.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources-300x153.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources-768x392.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/microsoft-sources.webp 894w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h4>3. Install .NET<\/h4>\n<p>Finally, update system package cache by running command:<\/p>\n<pre>sudo apt update<\/pre>\n<p>And, install .NET 8 SDK, runtime:<\/p>\n<pre>sudo apt install dotnet-sdk-8.0<\/pre>\n<p>For choice, you may replace <code>dotnet-sdk-8.0<\/code> with <code>dotnet-sdk-9.0<\/code> for .NET 9 (20.04 &amp; 22.04 only at the moment), or <code>dotnet-sdk-6.0<\/code> for .NET 6.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44747\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Option 3: Install .NET from Ubuntu PPA<\/h3>\n<p>Ubuntu team members also maintain a <a href=\"https:\/\/launchpad.net\/~dotnet\/+archive\/ubuntu\/backports\" target=\"_blank\" rel=\"noopener\">backport PPA<\/a>, which so far contains:<\/p>\n<ul>\n<li><b>.NET 6<\/b> and <b>.NET 7<\/b> for Ubuntu 24.04.<\/li>\n<li><b>.NET 9<\/b> for both Ubuntu 22.04 and Ubuntu 24.04.<\/li>\n<\/ul>\n<p>To add the PPA, open terminal (Ctrl+Alt+T) and run command:<\/p>\n<pre>sudo add-apt-repository ppa:dotnet\/backports<\/pre>\n<p><i>Type user password when it asks, though there&#8217;s no asterisk feedback, and hit Enter to continue.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet-backport-ppa.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47572\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet-backport-ppa-700x505.webp\" alt=\"\" width=\"610\" height=\"440\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet-backport-ppa-700x505.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet-backport-ppa-300x216.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet-backport-ppa.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Then, install .NET 9 by running command:<\/p>\n<pre>sudo apt install dotnet9<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet9.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47571\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet9-700x505.webp\" alt=\"\" width=\"610\" height=\"440\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet9-700x505.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet9-300x216.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/apt-dotnet9.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Or install .NET 6 or 7 (replace number 6 in command accordingly), if you want, in Ubuntu 24.04 via command:<\/p>\n<pre>sudo apt install dotnet6<\/pre>\n<h3>Option 4: Install .NET via Snap package<\/h3>\n<p>All current Ubuntu users can also install .NET as Snap package, through it runs in sandbox environment.<\/p>\n<p>Simply launch Ubuntu Software or App Center, then search &#8216;dotnet&#8217; filter by Snap package and click install. At the moment of writing, only .NET 8 is available.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47573\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap-700x430.webp\" alt=\"\" width=\"610\" height=\"375\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap-700x430.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap-300x184.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap-768x472.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/11\/dotnet8-snap.webp 1062w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Uninstall .NET<\/h3>\n<p>To remove .NET <code>.deb<\/code> package, open terminal (Ctrl+Alt+T) and run command:<\/p>\n<pre>sudo apt remove --autoremove dotnet9* dotnet-host-9.0 dotnet-sdk-9.0 dotnet-runtime-9.0<\/pre>\n<p>As well, replace number 9 in the command above, according to which version you installed and want to uninstall.<\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to install Microsoft .NET software development framework (9.0, 8.0, or even 6.0, 7.0) in current Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 LTS. Microsoft announced .NET 9 last week. It features over 1,000 performance related changes across the runtime, workloads, and languages. .NET Aspire 9 now has OpenAI, Ollama, Milvus integration, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":44743,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2090,2251],"class_list":["post-47568","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-microsoft","tag-net"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=47568"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47568\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/44743"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=47568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=47568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=47568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}