How to install Ubuntu on Windows 11 or 10 with a Single command?

Ubuntu is a user-friendly Linux distro used by both beginners and advanced users, however, if you want to use its minimal command line version on Windows 11 or 10 then WSL is the best option. It allows to run Ubuntu and other Linux distros via the command line interface. WSL is a safe option to experience Linux instead of installing it in the dual boot environment if you don’t want to use a virtual machine like Virtualbox or Hyper-V.

Well, if you have not enabled the WSL yet on your system then don’t need to go through various steps to download and install the Ubuntu Linux app on Windows 11 or 10, just a single command is all you need to run. In this article, we learn how to use that.

Prerequisites

  • We need a Windows 10 or 11 system
  • Access to Command Prompt or PowerShell as Admin
  • Active Internet connection to download the packages

Open PowerShell or CMD

Depending upon your choice of command line app you can access either PowerShell or command prompt on Windows. Here we are using CMD, so click on the Start button and search for “command prompt” as it appears in the results, select the “Run as Administrator” option.

open CMD as administrator

Command to install Ubuntu on Windows 10 or 11

As you have the Command Prompt, simply run the given command that not only downloads and installs the Ubuntu 22.04 version but even enables WSL and Virtual Machine Platform, if not already. The latest LTS version of Ubuntu while doing this article was 22.04, hence we are installing the same. You can change the version in the given command.

wsl --install --distribution Ubuntu-22.04
Installing Ubuntu on Windows using command

Note: If you want to check what are the available distros for installation, you can use the given command:

wsl --list -o

Whereas, if you want to use WSL 1 instead of WSL2 which will enable the “Virtual Machine Platform” then add the following option in the command while installing the Ubuntu or any other distro:

--enable-wsl1

Example: Let’s say we want to install Ubuntu-22.04 using the command but in the WSL1 environment instead of WSL2, then the command will be like this:

wsl --install  --enable-wsl1 --distribution Ubuntu-22.04

Once the installation is completed, the system may ask you to reboot it if it has enabled any feature of the Windows. Nevertheless, it is recommended to restart your system.

Check the Installed distros and corresponding WSL version

Once you have completed the previous step, we can check whether the Ubuntu is installed on our Windows successfully or not. Apart from that, we can also list which version of WSL is used by each Linux distro/app.

wsl -l -v
check Linux distro WSL version

Access the Ubuntu command line

To access the Ubuntu WSL Linux app, go to the search box and type – Ubuntu, you will see its icon click that to access the terminal. Where you can start running the commands.

Ubuntu 22.04 is installed

So, in this way, we can add the Ubuntu WSL app on Windows 10 or 11 using the command prompt or Powershell. It is quite easy and users don’t need to enable any feature using the GUI manually.

How to convert existing WSL 2 Ubuntu to WSL 1 or vice versa

Setting WSL Version to 1 for Ubuntu is quite easy using the command line. Access the PowerShell or CMD as Admin and then use the given command syntax. Here we are showing an example of how to convert the installed Ubuntu distribution WSL2 to WSL1 you can use it for others as well:

 wsl --set-version Ubuntu-22.04 1

Whereas for setting WS1 distro back to WSL2 just change value 1 to 2 in the command. Also, remember that WSL 2 needs Virtual Machine Plaftom enabled, so don’t forget to Turn it On, before converting the WSL 1 Linux version to WSL 2.

wsl --set-version Ubuntu-22.04 2

Common FAQs

  • What is Windows Subsystem for Linux (WSL)?

WSL by Microsoft is a compatibility layer implemented in Windows 10 and 11 operating systems for natively running the executable Linux binaries. This means there is no need to use additional Virtualization software like VMware or VirtualBox to get the GNU/Linux environment.

  • What is the command to install WSL on Windows 10 or 11?

Just run the PowerShell or Command Prompt as Administrator and then run the “wsl –install” command, it will automatically enable the WSL feature on Windows along with that a default Linux distro (Ubuntu) will also configured to run the commands.

  • Is this possible to have both WSL1 and WSL2 on the same Windows system?

Yes, it is pretty much possible to have both WSL1 and WSL2 configured Linux distros on the same Windows PC. Even, we can set a default version of WSL for each installed Linux distro app.

  • What is the command to switch our Linux from WSL1 to WSL2 or vice-versa?

wsl –set version” is the command that will convert the existing WSL1 Linux distro to WSL2 or vice versa. For example, if we have an Ubuntu-22.04 distro and want to change that to WSL2 then the command will be “wsl –set-version Ubuntu 2“, the last digit “2” in the command means WSL 2 and if you change that to 1, it will for WSL1.

  • Does WSL2 perform better than WSL2?

Yes, there are significant performance improvements in WSL2 over WSL1 because it uses the full-fledged Linux kernel and can access the GPU to perform intensive tasks. Even WSL 2 running distros can install GUI applications and Docker.

  • Will I need to enable Hyper-V to use WSL2?

No, we exactly don’t need to enable the Hyper-V feature in Windows to get WSL2 instead it needs a Virtual Machine Platform feature that makes the virtualization available for WSL2, and Hyper-V (if enabled) on the supported hardware.

  • Does WSL support and run graphical Linux applications?

The WSL2 with the Virtual Machine Platform feature enabled can run the graphical applications of Linux, however, this is not possible with WSL1 because it doesn’t have a full-fledged Linux kernel and also does not support Virtualization.

  • How to use the Ubuntu WSL terminal to access Windows files?

Open the Ubuntu WSL terminal and then access the /mnt/ directory where the Windows file systems are mounted. Let’s say you want to access the C: drive of WIndows in Ubuntu WSL then type “cd /mnt/c“, this will mount the C drive and give you access to its files.

  • How to run Windows applications from the Ubuntu terminal in WSL?

Just like we run the Windows applications from Command Prompt, we can open the Windows 10 or 11 programs directly from the Ubuntu terminal in WSL. For example to open Notepad from the WSL terminal just type – notepad.exe; don’t forget to use the .exe suffix with the command.

  • How do I update Ubuntu in WSL?

As we update Ubuntu on any other machine the same is applicable on WSL as well. Simply open the Ubuntu WSL terminal and run “sudo apt update && sudo apt upgrade. The system will download and install the updates from the official repositories.

1 thought on “How to install Ubuntu on Windows 11 or 10 with a Single command?”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.