Menu Close

How to Install Ubuntu on Windows with WSL 2: A Beginner’s Guide

Posted in Linux Tutorial

You do not need a second computer or a dual-boot setup to start learning Linux. Windows Subsystem for Linux, or WSL, lets you run Ubuntu alongside your Windows applications.

This guide covers installation, your first Linux account, basic commands, and file access. The main instructions use Windows 11. No Ubuntu ISO or USB installer is required.

1. Understand WSL, Ubuntu, and Windows Terminal

WSL provides the environment that allows Linux to run on Windows. Ubuntu is a Linux distribution installed in that environment, providing command-line tools, libraries, and a package manager.

WSL 2 runs a real Linux kernel in a lightweight virtual machine managed by Windows. You do not need to configure a traditional virtual machine yourself.

Windows Terminal is the application that can display different command-line sessions, including PowerShell and Ubuntu. Opening Terminal does not automatically mean that you are inside Linux. Check which profile or tab is active.

Ubuntu on WSL normally starts with a command line. A full Ubuntu desktop is not required for this tutorial.

2. Check Your Windows System

Use an updated Windows 11 computer, an internet connection, and an account with permission to approve administrator actions.

Microsoft’s simplified installation command also supports Windows 10 version 2004, build 19041, or later. This is a technical installation requirement; it does not indicate the support status of your Windows release.

To check your version, press Windows + R, type winver, and press Enter.

WSL 2 requires hardware virtualization. Open Task Manager with Ctrl + Shift + Esc, select Performance, and open the CPU page. Look for Virtualization: Enabled.

If virtualization is disabled, follow your computer manufacturer’s instructions to enable it in UEFI or BIOS. The setting may be described as Intel Virtualization Technology, VT-x, AMD-V, or SVM.

3. Open PowerShell as Administrator

Open the Start menu and search for PowerShell. Right-click Windows PowerShell and select Run as administrator. Approve the Windows permission prompt.

On Windows 11, you can also right-click Start, choose Terminal (Admin), and use a PowerShell tab.

The installation commands in the next section belong in Windows PowerShell.

4. Install WSL and Ubuntu

In administrator PowerShell, run:

wsl --install

On a fresh setup, this enables the required components and installs Ubuntu as the default Linux distribution. The exact sequence depends on which components are already installed.

Wait for the process to finish. If Windows requests a restart, save your work and restart the computer. You may need to continue the Ubuntu installation after restarting.

If WSL is already installed but Ubuntu is missing, run:

wsl --install -d Ubuntu

The -d option specifies the distribution. To see the available distribution names, use:

wsl --list --online

You can also install an official Ubuntu distribution from Microsoft Store after enabling WSL. Choose either the command-line route or the Store route; you do not need to install the same distribution twice.

5. Launch Ubuntu and Create Your Account

Open Start, search for Ubuntu, and launch the installed application. If it has already opened automatically, continue in that window.

The first launch may take longer because Ubuntu needs to initialize its files. Follow the prompts to create a Linux username and password.

For example, your username could be steve. A simple lowercase username is convenient for beginners.

Your Ubuntu account is separate from your Windows account. Its password can be different from your Windows password or PIN.

When typing a Linux password, the screen normally shows no characters or asterisks. This is expected. Type the password and press Enter, then confirm it when asked.

After setup, you should see a prompt similar to:

steve@MYPC:~$

Your username and computer name will differ. The tilde, ~, represents your home directory. The dollar sign is part of the prompt; do not type it when copying commands.

6. Verify That Ubuntu Uses WSL 2

Open a Windows PowerShell tab or window and run:

wsl --list --verbose

The shorter form is:

wsl -l -v

Example output:

  NAME      STATE           VERSION
* Ubuntu    Running         2

NAME identifies the installed distribution. STATE shows whether it is running or stopped. VERSION shows whether it uses WSL 1 or WSL 2. The asterisk marks the default distribution.

A value of 2 means Ubuntu uses WSL 2. It is not the Ubuntu release number. A Stopped state simply means the distribution is not currently running.

Use the exact distribution name shown on your computer in commands that specify a distribution.

7. Update Ubuntu Packages

Return to the Ubuntu window. Run:

sudo apt update

Enter your Ubuntu password if requested. This command refreshes the package information from Ubuntu’s configured software repositories.

Next, run:

sudo apt upgrade

Review the proposed changes. If asked whether to continue, enter Y and press Enter.

The sudo command allows an authorized user to run an operation with elevated privileges. The apt command manages Ubuntu software packages.

Updating WSL and updating Ubuntu packages are separate tasks. To update WSL itself, use wsl --update in Windows PowerShell. Use Ubuntu’s package manager to maintain the software inside Ubuntu.

8. Run Your First Linux Commands

In Ubuntu, check your username:

whoami

Move to your home directory and display its path:

cd ~
pwd

If your username is steve, the path should be:

/home/steve

Display the Ubuntu release information:

cat /etc/os-release

Display the Linux kernel release:

uname -r

These commands answer different questions. The first identifies the Linux distribution and release. The second identifies the running kernel.

9. Create a Practice Directory and File

Run the following commands one line at a time in Ubuntu:

mkdir -p ~/linux-practice
cd ~/linux-practice
echo "Hello from Ubuntu on Windows" > hello.txt
cat hello.txt

The commands create a directory, enter it, write a message into a file, and display the file’s contents.

Expected output from the final command:

Hello from Ubuntu on Windows

List the directory contents:

ls

You should see hello.txt. The > symbol writes output to a file and replaces its existing contents if the file already exists.

10. Access Files Between Ubuntu and Windows

While inside your practice directory, run:

explorer.exe .

There is a space before the final period. The period means the current directory. This command opens that directory in Windows File Explorer.

You can also enter the following path in File Explorer’s address bar:

\\wsl$

Select your distribution, then browse to its home directory.

Windows drives are normally accessible from Ubuntu under /mnt. For example, the C: drive is mounted at /mnt/c. To list Windows user directories, run:

ls /mnt/c/Users

For projects primarily using Linux tools, keep the working files in the Linux filesystem, such as ~/linux-practice. This generally provides better performance than repeatedly accessing files across the Windows–Linux filesystem boundary.

11. Open, Exit, and Shut Down Ubuntu

To open Ubuntu later, use its Start menu entry. You do not need to install it again.

Alternatively, run this in PowerShell:

wsl -d Ubuntu

If Ubuntu is your default distribution, simply running wsl will open it.

To leave the current Ubuntu shell, run:

exit

Exiting a shell does not necessarily stop every background Linux process. To stop all running WSL distributions and the WSL 2 virtual machine, save your Linux work and run this in PowerShell:

wsl --shutdown

The next launch starts the environment again. Your saved Linux files remain available.

12. Troubleshoot Common Installation Problems

The install command displays help instead of installing Ubuntu

If WSL is already present, explicitly request the distribution:

wsl --install -d Ubuntu

The download remains at 0.0 percent

Microsoft documents an alternative download method:

wsl --install --web-download -d Ubuntu

This uses an online source instead of the Microsoft Store download path.

Ubuntu reports a virtualization or required-component problem

First restart Windows if the installer requested it. Then check that hardware virtualization is enabled. WSL 2 also requires Virtual Machine Platform, which the installation command normally attempts to enable.

If the problem continues, record the exact error message and consult Microsoft’s WSL troubleshooting documentation.

Nothing appears when you type a password

Hidden password input is normal. Type your Ubuntu password and press Enter.

PowerShell cannot find apt

The apt command belongs inside Ubuntu. Open an Ubuntu session before running Linux package commands.

Ubuntu is already installed

Start with wsl -l -v in PowerShell, then open Ubuntu and continue with the verification and practice sections. Reinstallation is unnecessary.

Conclusion

Installing Ubuntu with WSL can take only a few steps. The useful result is a Linux environment that you can open alongside Windows and use for real practice.

Once you can launch Ubuntu, update packages, identify your system, and create a file, you are ready to learn Linux navigation, permissions, shell scripting, and development tools.

Official References

Leave a Reply

Your email address will not be published. Required fields are marked *