微软出品：《如何下载和安装 Linux》
Linux 微软 WSL

> 
> 编者注：本文译自微软官方发布的指南。
> 
> 
> 


![](/data/attachment/album/202310/13/155914y9m9e31eyni7mb9o.jpg)


Linux 是一款操作系统，与 Windows 有许多相似之处，但由于其开源和高度定制化的特性，衍生出众多的版本。安装 Linux 的前提是，你需要决定一个安装方式，并选定一个适合的 Linux 发行版。


要安装 Linux，你需要如下步骤：


1. 首先，确定一个安装方式。你可以选择使用 <ruby> Windows 的 Linux 子系统 <rp>  （ </rp> <rt>  Windows Subsystem for Linux </rt> <rp>  ） </rp></ruby>（WSL）进行安装，也可以选择完全安装在物理硬件上（即裸机安装），或者在本地或云端创建一个虚拟机（VM）来运行 Linux。
2. 其次，选择一个 Linux 发行版。如：Ubuntu、Debian、Kali Linux、OpenSUSE 等。
3. 然后，按照你所选的安装方法进行操作。具体可以是以下四种方式之一：
	* 使用 Windows 子系统 Linux（WSL）中的安装 Linux 命令
	* 在云中创建一个 Linux 虚拟机（VM）
	* 在本机创建一个 Linux 虚拟机（VM）
	* 创建一个可引导的 USB，以安装裸机版 Linux
4. Linux 安装完成后，你需要熟悉你所选发行版的包管理器，更新和升级可获取的包，并熟悉微软提供的 Linux 资源，比如培训课程、为 Linux 设计的流行工具、新闻以及开源活动等。


### 步骤 1：选择一个安装 Linux 的方法


至于如何选择安装 Linux 的方式，这主要取决于你的需求和喜好。


* **如果你是 Linux 新手**，我们推荐你首先尝试 Windows 的 Linux 子系统（WSL），这是入门 Linux 最简单的方法。
* **如果你正在企业环境中工作，或你在处理的业务有更复杂的需求**，如规模或安全性等方面，我们推荐你在云端运行 Linux 虚拟机，并查看 Azure 所能提供的帮助。此建议也适用于想要将 Linux 作为服务器的用户。
* **如果你只想将 Linux 作为你主要的操作系统**，可以选择在物理硬件上裸机安装 Linux，尽管这个安装过程稍微复杂一些，且你可能无法访问到 Windows 的工具（如 Outlook、Teams、Word、PowerPoint 等），但你可以全力发挥你硬件的全部性能，无需承担虚拟化或仿真的开销。


你可以在下文中了解这些选项的详细信息。


#### Windows 的 Linux 子系统（WSL）


Windows 的 Linux 子系统（WSL）是一个安装 Linux 的简便方式，适用于使用 Windows 机器的用户。这是安装 Linux 最简单的一种方式。你只需执行 Linux 的安装命令：`wsl --install`，即可安装 Ubuntu 发行版。


此方法通过虚拟技术，将 Windows 和 Linux 操作系统（后者运行在真实的 Linux 内核上）整合到一起。你可以根据需要添加任何数量的 Linux 发行版，并且可以方便地在 Windows 中运行你喜爱的 Linux 工具，包括图形界面应用。此外，你还可以在同一条命令行中混合使用 Bash 和 PowerShell 命令。在这种方式下，项目文件由 Linux 文件系统托管，你可能需要用到的开发工具（如 VS Code）则由 Windows 文件系统托管。此安装方式的效率高且性能优秀。选择 Linux 发行版（或默认的 Ubuntu 发行版）后，你可以按照 Windows 的 Linux 子系统下的 [Linux 安装命令](https://learn.microsoft.com/en-us/linux/install#install-linux-with-windows-subsystem-for-linux) 进行操作，或在 [WSL 文档](https://learn.microsoft.com/en-us/windows/wsl) 中查阅更多信息。


![WSL install command screenshot](/data/attachment/album/202310/13/155930jsn6dl2ndcvzcrlr.png)


#### 创建虚拟机（VM）


创建虚拟机（VM）的选项适合所有人，无论你正在使用 Windows 还是 MacOS。然而，如果你想在云端创建虚拟机，你需要有一个 Azure 账户，或者如果你打算在你的电脑上直接创建虚拟机，你需要安装虚拟化软件。


虚拟机实际上是真实计算机的数字版，对于在可能需要提高硬件支持（例如：需要更多内存和处理能力）以及安全级别（如防病毒、加密、备份、策略管理等）的环境中运行 Linux 的场景非常受欢迎。


就像使用 WSL一样，你可以根据自己的需求创建多个不同 Linux 发行版的虚拟机实例，这些虚拟机在相互独立的环境中运行，它们没有任何冲突，非常适合进行软件开发和测试。虽然在 WSL 上运行 Linux 发行版的性能稍微更优，但 Linux 虚拟机更易于复制和迁移。可以根据你的需求，在 Azure 等云服务上或者通过虚拟化软件（也称为 <ruby> 管理程序 <rp>  （ </rp> <rt>  hypervisor </rt> <rp>  ） </rp></ruby>）在自己的电脑上创建虚拟机。


在 Azure 上创建虚拟机，实际上是在云端的微软的服务器上托管你的虚拟机，你只是在向微软租用计算资源以运行虚拟机。这种方式在当你需要快速配置新的虚拟机或需要运行需求超过你个人电脑能力的任务时，将非常方便。大规模企业，由于其对扩展性、控制和功能需求更高，往往选择 [在 Azure 上运行 Linux 虚拟机](https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/n-tier/linux-vm)。


在本地计算机上创建虚拟机需要使用虚拟化软件，即管理程序。Windows 提供了一个名为 [Hyper-V](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/) 的 “类型 1” 管理程序，可以直接在你的硬件上运行虚拟化。此外，还有一些在操作系统上运行的“类型 2” 管理程序，比如 VirtualBox 或 VMware。如果你使用的是 Mac，一般推荐使用的管理程序是收费的“Parallels Desktop”。如果你想了解更多关于在配备了苹果硅芯片的 Mac 上如何安装 Linux 虚拟机的信息，可以参考对应的 [安装教程](https://kb.parallels.com/128445)。需要指出的是，[VirtualBox](https://www.virtualbox.org/wiki/Downloads) 支持 Windows 和 MacOS。有关于如何在苹果硅芯片或基于英特尔的 Mac 上设计并运行自定义 Linux 客户机的更多信息，请参考 [这篇](https://developer.apple.com/documentation/virtualization/creating_and_running_a_linux_virtual_machine)。


使用虚拟机管理器时，你需要自行管理虚拟机，包括分配内存、磁盘空间等资源，并确保系统的安全和及时性。相比其他选项，这需要更多的技术专长，并且可能无法达到同等的扩展性和容错容忍度。


一旦你选定了 Linux 发行版，并决定是在 [本地通过虚拟机管理器运行虚拟机](https://learn.microsoft.com/en-us/linux/install#create-a-linux-virtual-machine-locally-using-a-hypervisor)，还是 [在云端通过 Azure 运行](https://learn.microsoft.com/en-us/linux/install#create-a-linux-virtual-machine-in-the-cloud)，你就可以按照相应的说明，在云上或在本地创建 Linux 虚拟机。


![Create a Linux VM on Azure screenshot](/data/attachment/album/202310/13/155931k2tq839mn3m0tadd.png)


#### 裸机 Linux


所谓的裸机 Linux，意味着 Linux 是直接在设备硬件上运行。要进行裸机安装，你需要从你选择的 Linux 发行版官方网站下载 ISO 安装文件，并从这个文件创建一个可启动的 USB 驱动器。为了完成这个步骤，你需要一个已经安装有操作系统（Windows 或者其他操作系统）的设备。


许多用户选择裸机安装 Linux，并在同一台设备上与 Windows 共存，这就需要利用所谓的“双启动”模式。使 Windows 和 Linux 能双启动，就需要对你的硬盘进行分区，以保证两个操作系统（Linux 和 Windows）都有各自独立的空间。尽管 WSL、虚拟机和裸机 Linux 的性能已经相差无几，但由于双启动方式需要在两个操作系统间切换的时候频繁重启设备，所以这种安装方式并不是首选。此外，如果选择裸机安装 Linux，还需要对可能出现的设备驱动或硬件兼容性问题做好准备。


你可以在 [Linux.org](https://linux.org/pages/download/) 网站上找到各种可供下载的主流 Linux 发行版。在你选定一个发行版之后，按照指南制作一个 [可启动的 USB 驱动器](https://learn.microsoft.com/en-us/linux/install#create-a-bootable-usb-drive-to-install-bare-metal-linux)，进行裸机 Linux 的安装就可以了。


![Create a bootable USB screenshot](/data/attachment/album/202310/13/155931goxb66oi3okkuko3.png)


### 步骤 2：选择一个 Linux 发行版


Linux 的不同版本被称为“发行版”。因此，实际上并没有一个简单的“安装 Linux”的方法，你需要首先选择你想下载和安装哪一个使用了 Linux 内核的发行版。目前存在超过 600 种活跃的 Linux 发行版，如 Ubuntu、Debian、Kali Linux、OpenSUSE 等。在选择发行版时，有许多因素需要考虑，如：


#### 需要 Linux 经验


如果你是 Linux 新手，可能会首选 Ubuntu。由于其支持健全且易用，Ubuntu 是 Linux 用户的主要起点之一。Ubuntu 提供了桌面版和服务器版供你选择，具体使用哪个版本由你打算如何使用它决定。操作系统需要负责的具体任务可能帮助你确定使用哪个发行版。Arch Linux 对于希望具有高度自定义、自行决定如何配置，但仍然稳定且得到大用户群支持的用户来说是个不错的选择。从这个地方开始可能会更复杂，但可以帮助你更好地理解 Linux 如何工作。


#### 系统要求


如果需要一个资源消耗较少，或者说“轻量级”的发行版，就需要考虑对内存和处理速度需求较低的发行版。Alpine Linux 是一个热门的选择，用户会发现大部分的功能默认关闭或者没有安装，但这个发行版仍有你运行一个容器化应用所需的所有东西。


#### 安全需求


有些 Linux 用户可能有特殊的安全需求需要考虑。Kali Linux 是设计用于进行安全任务如渗透测试、安全研究、计算机鉴识和逆向工程的发行版的一个例子。


#### 对商业和企业环境的需求


与普通用户环境相比，商业、企业或者学术环境可能有着各自独特的要求。红帽企业 Linux（RHEL）和 Oracle Linux 提供全天候的全球支持和订阅服务。CentOS 也是一款备受欢迎的企业级发行版，它由社区支持，同时与 RHEL 具有良好的兼容性。


#### 社区支持


具有强大用户社区的发行版往往受到青睐，因为这样的社区可以持续对发行版作出贡献，包括修复问题，增加新的功能，解答使用中的问题等。Ubuntu 就是最受欢迎的发行版之一，而 OpenSUSE 的历史比大多数其他发行版更悠久，且仍然在活跃更新中。随着用户需求和喜好的变化，许多其他的发行版也迅速赢得了用户的喜爱。Linux.org 网站提供了一些资源帮助你了解哪些发行版具有良好的支持或正在日益受到欢迎。


![Screenshot of the list of distributions on Linux.org](/data/attachment/album/202310/13/155931cnm7jnnp7pjjmmnn.png)


### 步骤 3：按照安装方法步骤执行安装


#### 在 Windows 的 Linux 子系统（WSL）中安装 Linux


若在 Windows PC 上安装 Linux，需要执行 Linux 安装命令。


1. 首先，通过右键点击选择 “<ruby> 以管理员身份运行 <rp>  （ </rp> <rt>  Run as administrator </rt> <rp>  ） </rp></ruby>” 来打开 PowerShell 或 Windows 命令提示符。
2. 执行 Linux 安装命令：`wsl --install` 。
3. 然后，重启你的电脑。


![WSL Linux Install List Command screenshot](/data/attachment/album/202310/13/155931qc7rrc7rx8iigmrg.png)


##### Linux 安装命令的选项


默认情况下，安装命令会选择 Ubuntu 的 Linux 发行版。你可以查看微软商店中的其它可用发行版，方法是输入命令：`wsl -l -o` 。如需安装 Ubuntu 之外的其它发行版，在安装命令后加上 `-d` 参数，然后输入你想安装的发行版的名称：



```
wsl --install -d <发行版名称>
```

若你想安装的发行版不在微软商店中，你可参照 WSL 文档，学习如何 [导入](https://learn.microsoft.com/en-us/windows/wsl/use-custom-distro) 你想与 WSL 一起使用的任何 Linux 发行版。


若想获取更多关于如何使用 VS Code、Git、Database、Docker、GUI apps、GPU 加速、NodesJS、USB 设备、挂载磁盘、创建自定义发行版、管理磁盘空间、为企业业务设置 WSL 的信息，你可以查阅 [WSL 的文档](https://learn.microsoft.com/en-us/windows/wsl/)。


#### 在云端创建 Linux 虚拟机


若想在 Azure 云上创建由 Linux 支持的虚拟机（VM），你需要登录 Azure Portal，并选择 “<ruby> 创建虚拟机 <rp>  （ </rp> <rt>  Create a Virtual Machine </rt> <rp>  ） </rp></ruby>” 服务。然后，按照指示完成用户名、项目、实例、SSH 密钥、端口设置，并复制 IP 地址。


Azure 提供了多种在云上创建 Linux VM 的选项。你可以选择喜欢的方法创建 Linux VM，快速指南选择方法如下：


* [Azure Portal](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu&source=docs)
* [Azure CLI](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli)
* [Azure PowerShell](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-powershell)
* [Terraform](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-terraform)
* [Bicep 文件](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-bicep?tabs=CLI)
* [Azure 资源管理器（ARM）模板](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-template)


如果你还没有 Azure 订阅账户，可以在开始之前创建一个 [免费账户](https://azure.microsoft.com/free/)。如果这是你第一次在 Azure 上创建 Linux VM，你可以学习更多 [有关 VM 的知识](https://azure.microsoft.com/resources/cloud-computing-dictionary/what-is-a-virtual-machine)，或者查看在线培训课程：[在 Azure 上创建 Linux 虚拟机](https://learn.microsoft.com/en-us/training/modules/create-linux-virtual-machine-in-azure/)。


![Select Linux VM size on Azure screenshot](/data/attachment/album/202310/13/155931kbtpaj2ep2bhvnxj.png)


#### 使用虚拟机管理程序在本地创建 Linux 虚拟机


要在你的本地机器上使用虚拟机管理程序创建 Linux 虚拟机，你可以选择使用：


* [Windows Hyper-V](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/)
* [VirtualBox](https://www.virtualbox.org/)
* [VMware](https://docs.vmware.com/en/VMware-Horizon-7/7.13/linux-desktops-setup/GUID-51C371A9-4D76-4A8C-8645-909E93080B4F.html)


首先，你需要根据你所选择的管理程序检查硬件需求。在管理程序启用或安装后，你需要确定你想要安装的操作系统类型及其安装源（一般为 .iso 或 .vhdx 文件）。给虚拟机命名，选择文件存储的目录，设置分配给虚拟机的内存和虚拟硬盘大小（通常可以在固定或动态分配的硬盘空间中选择）。由于显示驱动和其他硬件依赖关系，有时候整合 Linux 虚拟机可能比较棘手，但大部分的管理程序都有活跃的用户社区，可以提供必要的帮助。如果你希望你的虚拟机能够连接到网络，可能还需要设置一个虚拟网络。


如果你刚接触管理程序，想要了解更多的话，可以尝试免费的在线课程：[配置和管理 Hyper-V 虚拟机](https://learn.microsoft.com/en-us/training/modules/configure-manage-hyper-v-virtual-machines/)。


![Hyper-V install screenshot](/data/attachment/album/202310/13/155932xpnjx5npz9nrqvj3.png)


#### 创建可引导的 USB 驱动器以安装裸机 Linux


如果你需要裸机的 Linux，不论是在设备上单独运行某个发行版，还是在该发行版和 Windows 之间进行双启动，皆可以按照以下步骤进行：


1. 下载你所选的 Linux 发行版的镜像文件，一般是 ISO 文件，例如，你可以在 [Ubuntu 桌面版下载](https://ubuntu.com/download/desktop) 页面下载最新版的 Ubuntu 镜像。有些 Linux 发行版可能在下载前需要你验证镜像签名。
2. 创建一个可引导的 USB 驱动器。你通常需要一个至少有 16GB 空间的 USB 驱动器。同样，你也需要一个可以创建引导驱动器的软件，例如 balenaEtcher、Rufus、UNetbootin 等。通常情况下，你选择的 Linux 发行版的下载页面会推荐使用哪种引导盘创建软件。
3. 从 USB 驱动器启动你的设备。在设备重启时，你需要进入启动菜单，这通常通过在启动期间按下 `F12` 键来实现。然后你可以选择安装包含有你的 Linux 发行版本 ISO 文件的 USB 驱动器。
4. 选择安装选项。通常，你的 Linux 发行版的安装器会包括一系列安装步骤，这些步骤中会包含是否包括某些特性、第三方软件包等的选项。你还可能需要在该 Linux 发行版会是唯一操作系统的情况下选择是否对磁盘进行清除，或者如果你计划运行多个操作系统，你可能需要使用一个分区。你也可能会被询问是否希望启用加密。
5. 最后，与任何 Linux 安装一样，你需要创建一个用户名和密码。


![Ubuntu install screenshot](/data/attachment/album/202310/13/155932icmp7y2oy83sn2en.png)


### 步骤 4：Linux 安装成功后需要进行的操作


在你成功安装 Linux 发行版后，还需要进行以下几个重要的步骤：


1. 首先，熟悉你选择的 Linux 发行版所使用的首选包管理器。Linux 通过包管理器来下载和更新你打算使用的所有软件。例如，Ubuntu 就使用了 [Advanced Packaging Tool](https://ubuntu.com/server/docs/package-management)（APT）。
2. 进一步，利用你的发行版的包管理器进行发行版的更新和升级。稳定的 Linux 发行版中的软件包往往已经过时，因此我们建议你定期更新你的系统。同时，你可能希望进行升级操作，它会更新你已经安装的所有包文件的版本。如你使用的是 Ubuntu，那么你可以运行命令：`sudo apt update && sudo apt upgrade`。
3. 除此之外，探索 Microsoft 提供的 [Linux 资源](https://learn.microsoft.com/en-us/linux/) 也非常重要，例如针对 Linux 的 Microsoft 工具（如 Visual Studio Code、.NET 和 PowerShell），Learn 目录中可供学习的免费 Linux 相关课程，以及关于事件、新闻和 Linux 组织与 Microsoft 之间的持续伙伴关系的信息，包括 Microsoft 支持的 Mariner 发行版。


*（题图：MJ/36b362bf-a6c5-4e60-b279-65b67e157872/）*




---


via: <https://learn.microsoft.com/en-us/linux/install> 


作者：[mattwojo](https://github.com/mattwojo) 译者：[ChatGPT](https://linux.cn/lctt/ChatGPT) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](/article-16278-1.html) 荣誉推出


OK
# How to download and install Linux

Linux is an operating system, similar to Windows, but with many different versions due to the nature of being open source and fully customizable. To install Linux, you must choose an install method and choose a Linux distribution.

To install Linux:

[Choose an install method](#step-1---choose-a-method-to-install-linux): Windows Subsystem for Linux (WSL), Bare metal Linux; or create a Virtual Machine (VM) to run Linux locally or in the cloud.[Choose a Linux distribution](#step-2---choose-a-linux-distribution): Ubuntu, Debian, Kali Linux, openSUSE, etc.[After installing Linux](#step-4---after-installing-linux): Get familiar with your distribution's package manager, update and upgrade the packages available, and get familiar with the other[Linux resources at Microsoft](./), such as training courses, Linux-versions of popular tools, news, and Open Source events.

## Step 1 - Choose a method to install Linux

The choice of which method to use for installing Linux depends on your needs and preferences.

**New to using Linux?**We recommend starting with Windows Subsystem for Linux (WSL) as it's the easiest way to get up and running.**Work in a business environment with more complex needs related to scale or security?**We recommend running Linux as a Virtual Machine (VM) in the cloud and checking out the support that Azure has to offer. This also applies if you want to run Linux as a server.**Only want to run Linux as your primary operating system?**If you are good with a slightly more complicated install process and don't need access to Windows tools (like Outlook, Teams, Word, PowerPoint, etc), you can run Linux on bare metal to access the full potential of your hardware without any overhead from virtualization or emulation.

Learn more about these options below.

### Windows Subsystem for Linux (WSL)

Available to those with a Windows machine, this is the most simple way to install Linux. Just run the Linux install command: `wsl --install`

to install the Ubuntu distribution.

This method uses virtualization to integrate the Windows operating system (OS) with the Linux OS (running on an actual Linux kernel). You can add as many different Linux distributions as you please and run your favorite Linux tools, including GUI apps, alongside your favorite Windows tools. You can also mix and match Bash and PowerShell commands in the same command line. A Linux file system hosts your project files, while a separate Windows file systems hosts any developer tools, such as VS Code, that you'd like to work on the files with. This method of running Linux is highly efficient and performant. Once you choose a Linux distribution or opt to use the default Ubuntu distro, follow the instructions to [Use the install Linux command with Windows Subsystem for Linux](#install-linux-with-windows-subsystem-for-linux) or learn more in the [WSL documentation](/en-us/windows/wsl).

### Create a Virtual Machine (VM)

Available to everyone regardless if you're using a Windows or MacOS-based machine, but will require either an Azure account, if creating a VM in the cloud, or virtualization software, if creating a VM directly on your machine (locally).

A VM is a digital version of a physical computer and is a popular option for running Linux in environments that may require you to scale the level of hardware support (Memory and processing power required) and the level of Security (antimalware, encryption, backups, policy management, etc).

Like with WSL, you can create VM instances of as many different Linux distributions as you'd like, running them in an isolated environment, free from any conflicts and great for software development testing. While running a Linux distribution on WSL has slightly faster performance, a Linux VM is easier to clone or migrate. You can create a virtual machine on a cloud service like Azure or on your local machine, using virtualization software (otherwise known as a hypervisor).

Creating a VM on Azure means that it's hosted in the cloud, on Microsoft's servers. You are essentially renting computing resources from Microsoft and using them to run the VM. This can be convenient if you need to quickly provision a new VM or need to run a workload that requires more computing resources than your local computer can provide. Larger businesses with more complex needs often choose to run Linux VMs on Azure for its scalability, control and abundance of features. Learn more about the architecture, workflow, and considerations to [Run a Linux VM on Azure](/en-us/azure/architecture/reference-architectures/n-tier/linux-vm).

Creating a VM on your local machine requires virtualization using a hypervisor. Windows includes a "type 1" hypervisor called [Hyper-V](/en-us/virtualization/hyper-v-on-windows/) to run virtualization directly on your device hardware. There are also "type 2" hypervisors that run on top of the operating system, like VirtualBox or VMware. If you are using a Mac, the most commonly recommended hypervisor is "Parallels Desktop", though this is a paid service. See [Install Linux VM on a Mac with Apple M-Series chip](https://kb.parallels.com/128445). [VirtualBox](https://www.virtualbox.org/wiki/Downloads) also supports both Windows and MacOS. See [Creating and Running a Linux Virtual Machine](https://developer.apple.com/documentation/virtualization/creating_and_running_a_linux_virtual_machine) for more about how to design and run custom Linux guests on Apple silicon or Intel-based Macs.

You are responsible for managing the virtual machine when using a hypervisor, including allocating resources like memory and disk space, and ensuring that it is secure and up-to-date. This requires more technical expertise than some of the other options and may not be as scalable or fault-tolerant.

Once you've chosen a distribution and decided whether you want to run the VM locally, using a hypervisor, or in the cloud, using Azure, follow the instructions to [Create a Linux Virtual Machine in the Cloud](#create-a-linux-virtual-machine-in-the-cloud) or [Create a Linux Virtual Machine locally using a Hypervisor](#create-a-linux-virtual-machine-locally-using-a-hypervisor)

### Bare metal Linux

Bare metal Linux just means that Linux is running directly on the device hardware. This install method requires you to create a bootable USB drive by downloading an iso install file from the site hosting your chosen Linux distribution. You will need to use a Windows computer (or any desktop device with an existing OS) to create this drive.

Many users choose the traditional method of installing bare metal Linux on a device that is also running Windows and using the **"dual boot"** method. To boot Linux and Windows, you need to partition your hard drive to create separate spaces for both the Linux and Windows OS. The performance speed between WSL, virtual machines, and bare metal Linux has become so close that few developers choose this method due to the overhead of needing to restart (reboot) your device any time you want to switch between the operating systems. If you choose the bare metal Linux install route, you may also need to deal with potential driver issues or hardware compatibility problems that may arise with Linux on some devices.

You can find a list of [Popular Linux Distributions available for download on Linux.org](https://linux.org/pages/download/). Once you've chosen a distro, follow the instructions to [Create a bootable USB to install bare-metal Linux](#create-a-bootable-usb-drive-to-install-bare-metal-linux).

Warning

If you are planning to dual boot or live boot a bare metal Linux distribution and your Windows machine is using [Bitlocker](/en-us/windows/security/operating-system-security/data-protection/bitlocker/) for encryption to protect data theft or exposure, be certain to [retrieve and store your BitLocker encryption keys](https://support.microsoft.com/windows/finding-your-bitlocker-recovery-key-in-windows-6b71ad27-0b89-ea08-f143-056f5ab347d6) prior to installing Linux. Learn more in this Microsoft Q&A: [Can I use Bitlocker with Dual-Boot setup?](https://answers.microsoft.com/en-us/windows/forum/all/can-i-use-bitlocker-with-dual-boot-setup/624f9920-4e9d-4824-abc4-405c60f8e6b0)

## Step 2 - Choose a Linux distribution

The different versions of Linux are called "distributions" (sometimes shortened to “distros”). So there isn’t actually a way to just “install Linux”, you first need to choose which distribution that uses the Linux kernel you want to download and install. There are over 600 active Linux distributions, such as Ubuntu, Debian, Kali Linux, openSUSE, and more. There are a number of factors to consider in choosing a distribution, such as:

### Required Linux experience

If you’re new to Linux, you may want to start with Ubuntu. This is one of the most common starting places for Linux users due to the level of support and ease of use. Ubuntu offers a desktop-version and a server-version depending on how you plan to use it. The specific tasks that the operating system will be responsible for may help you determine which distribution to use. Arch Linux is a popular choice for those who want a highly customizable, do-it-yourself approach that is still stable and well-supported by a large user base. It is a much more complicated place to start, but can help you to get a better understanding of how Linux works due to the amount of custom configuration.

### System requirements

A minimal, or "lightweight", distribution means a small footprint, with lower memory and processing speed requirements. Alpine Linux is a popular option where users will find most features disabled or not installed by default, but still has everything you need for a containerized app. Security needs: Some Linux users may have specific security concerns to consider. Kali Linux is an example of a distro designed for security tasks, such as Penetration Testing, Security Research, Computer Forensics and Reverse Engineering.

### Business and Enterprise requirements

Business, corporate, or academic environments may have unique concerns from consumer environments. For example Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES) and Oracle Linux offer 24/7 global support and subscription-based service. CentOS is another popular enterprise distro that is community-supported but still compatible with RHEL.

### Community support

A large user community that consistently contributes to the distribution, fixing bugs, adding features, helping with questions, etc. is another good consideration. Ubuntu is one of the most popular distos. openSUSE has been around longer than most other distributions and offers in addition to the stable version (Leap) a rolling version (Tumbleweed). Many other distros rapidly grow popular as the needs and preferences of the user community change. The Linux.org site has resources to help you assess what's available, well-supported, or growing in popularity.

## Step 3 - Follow install method instructions

### Install Linux with Windows Subsystem for Linux

To install Linux on a Windows PC, use the install Linux command.

- Open PowerShell or Windows Command Prompt in
*administrator mode*by right-clicking and selecting "Run as administrator". - Enter the Linux install command:
`wsl --install`

. - Restart your machine.

#### Install Linux command options

By default, the install command will use the Ubuntu distribution of Linux. You can see the other distributions that are available in the Microsoft Store by entering the command: `wsl -l -o`

. If you'd like to install a distribution other than Ubuntu, just add `-d`

to the command with the name of the distribution you'd like to install:

```
wsl --install -d <Distro Name>
```


If the distribution you want to install isn't available in the Microsoft Store, see the Windows Subsystem for Linux (WSL) documentation on how to [Import any Linux distribution to use with WSL](/en-us/windows/wsl/use-custom-distro).

For more information on how to use VS Code, Git, databases, Docker, GUI apps, GPU acceleration, NodesJS, USB devices, or mount a disk, build a custom distribution, manage disk space, or set up WSL for your enterprise business, see the [WSL documentation](/en-us/windows/wsl/).

### Create a Linux Virtual Machine in the cloud

To create a Linux Virtual Machine (VM) that is hosted in the cloud on Azure, log-in to the Azure Portal and select the “Create a Virtual Machine” service. Then follow the instructions for creating a user name, project, instance, SSH key, ports, and copying the IP address.

Azure supports a variety of options for setting up Linux VMs in the cloud. For a quickstart guide on how to set up a Linux VM, choose your preferred method:

[Azure Portal](/en-us/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu&source=docs)[Azure CLI](/en-us/azure/virtual-machines/linux/quick-create-cli)[Azure PowerShell](/en-us/azure/virtual-machines/linux/quick-create-powershell)[Terraform](/en-us/azure/virtual-machines/linux/quick-create-terraform)[A Bicep file](/en-us/azure/virtual-machines/linux/quick-create-bicep?tabs=CLI)[Azure Resource Manager (ARM) template](/en-us/azure/virtual-machines/linux/quick-create-template)

If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin. If you're new to creating Linux VMs with Azure, you can [learn more about VMs](https://azure.microsoft.com/resources/cloud-computing-dictionary/what-is-a-virtual-machine) or check out the online training course: [Create a Linux virtual machine in Azure](/en-us/training/modules/create-linux-virtual-machine-in-azure/).

### Create a Linux Virtual Machine locally using a hypervisor

To create a Linux VM that is hosted on your local machine using a hypervisor, you can use:

You will need to check the hardware requirements for your chosen hypervisor. Once the hypervisor is enabled or installed, you will need to choose the type of OS that you want to install and the installation source (this is typically a .iso or .vhdx file). You will need to give the VM a name, select the directory where files will be hosted, select the amount of memory to allocate to the VM and the size of the virtual hard drive where files will be stored (you can typically choose between a fixed or dynamically allocated amount of drive space). Sometimes integrations with a Linux virtual machine can be tricky due to display drivers and other hardware dependencies, but most hypervisors have an active user community that can help. You may also need to set up a virtual network if you want your VM to connect to the internet.

If you're new to hypervisors and want to learn more, try the free online training module: [Configure and manage Hyper-V virtual machines](/en-us/training/modules/configure-manage-hyper-v-virtual-machines/).

### Create a bootable USB drive to install bare-metal Linux

If you want bare-metal Linux, whether to run a distribution alone on a device or to dual-boot between the distribution and Windows, here are the steps:

- Download an image file for your chosen Linux distribution.
This is usually an ISO file. As an example, you can find an image file for the most recent version of Ubuntu at
[Download Ubuntu Desktop](https://ubuntu.com/download/desktop). Some Linux distributions may require you to verify the image signature before downloading. Some Linux distributions also cannot be installed unless Windows Secure Boot is disabled (which is not recommended). - Create a bootable USB drive. You will typically need a USB drive with at least 16gb of space. You will also need software to create the bootable drive. There are many options (such as balenaEtcher, Rufus, UNetbootin, etc.). Often the download site for your chosen Linux distribution will recommend which startup disk creater software to use.
- Boot your device from the USB drive. When restarting the device, you will need to enter the boot menu. This is typically done by holding down the F12 key during startup. You can then select the USB drive containing your Linux distribution ISO to install from.
- Select install options. Typically the installer for your Linux distribution will include a set of installation steps that will involve choosing options about whether you want to include certain features, third-party software packages, etc. You may also need to specify whether to erase the disk in the case that this Linux distro will be the only operating system, or to use a partition, if you plan to run multiple operating systems. You may also be asked about whether you'd like to enable encryption.
- Finally, as with any Linux installation, you will be asked to create a user name and password.

Important

You will need to remove the USB drive after installing, during the reboot.

## Step 4 - After installing Linux

Once you have successfully installed a Linux distribution, there are a few more important steps:

- Get familiar with the preferred package manager used by your chosen Linux distribution. Linux uses package manager's to download and update any software that you plan to use. For example, Ubuntu uses the
[Advanced Packaging Tool (APT)](https://ubuntu.com/server/docs/package-management). - Use your distribution's package manager to update and upgrade your distribution. Software packages in a stable release of a Linux distribution are often outdated. It is recommended to regularly run an update. You may also want to run an upgrade, which installs newer versions of any packages that you've already installed. For example, if you're using Ubuntu, run:
`sudo apt update && sudo apt upgrade`

. - Learn more about the
[Linux resources available at Microsoft](./), such as Linux-specific versions of Microsoft tools like Visual Studio Code, .NET, and PowerShell, free Linux-related training courses available from the Learn catalog, and information about events, news, and the ongoing partnerships between Linux organizations and Microsoft, including the Microsoft-supported Mariner distribution.

## Sudo for Windows

If you're using Windows, but accustomed to BASH commands, you may be interested in [Sudo for Windows](/en-us/windows/sudo/), a new way for users to run elevated commands (as an administrator) directly from an unelevated console session on Windows.