Installing Ubuntu Server 24.04 LTS on a Windows 11 Pro computer using WSL2

Post Reply
User avatar
Admin
Site Admin
Posts: 17
Joined: Sun May 10, 2026 10:15 pm

Installing Ubuntu Server 24.04 LTS on a Windows 11 Pro computer using WSL2

Post by Admin »

Installing Ubuntu Server 24.04 LTS on a Windows 11 Pro computer using WSL2



In this post we install and configure an instance of Ubuntu Server
under WSL2 for Linux. Many developers are going to choose to use WSL2,
so we guide them to install the Ubuntu Server version of WSL2. This
provides a more standard environment referenced by many howto procedures
on the Internet.

WSL2 enables a computer running Windows 11 Pro to host a guest instance of Ubuntu Server:

Image

WSL2 offers some advantages for a developer experience

WSL2 offers some advantages for a local developer in terms of
networking: if they install a service that opens a port, like port
22/tcp for SSH, that same port is opened on localhost of the Windows
machine hosting the WSL2 Ubuntu Server instance. A developer can SSH to
port 22 on localhost, without configuring a static IP address or port
forwarding. This eliminates the need to configure virtual switches,
static IP addresses, and port forwarding. In addition, WSL2 provides a
file mounts of the Windows file system within Linux, and a file mount of
the Linux filesystem within Windows.

Other ways to install Ubuntu Server on a Windows 11 Pro computer

There are other ways to install Ubuntu Server on a Windows 11 Pro
computer, including Windows Hyper-V. If you need to host multiple
instances of Ubuntu Server with static IP addresses and subnet routing,
consider using Hyper-V instead.

Installing WSL2

Start a CMD window as Administrator. At the Start menu, type the
letters “cmd” then right-click on the app icon to run the command prompt
as root:

Image

Enter the following command:

Code: Select all

1powershell
Image

Enter the following command:

Code: Select all

1wsl --install -d Ubuntu-24.04
Image

Image

Reboot your computer.

Image

Enter values for username and password:

Image

Enter the following command from a CMD window running as Administrator:

Code: Select all

1wsl --list --verbose
Image

Image

Enter the following command:

Code: Select all

1wsl --setdefault Ubuntu-24.04
Image

Enter the following command:

Code: Select all

1wsl
Image

Enter the following command:

Code: Select all

1lsb_release -a
Image

Enter the following command:

Code: Select all

1sudo su
Image

Updating apt packages on the Linux system

Enter the following commands:

Code: Select all

12apt cleanapt update
Image

Enter the following command:

Code: Select all

1apt upgrade
Image

Enter y for yes:

Image

Enter the following command:

Code: Select all

1reboot
Image

from a CMD window running as Administrator, enter the following command:

Code: Select all

1wsl
Image

Installing some utilities

Enter the following commands:

Code: Select all

12sudo suapt install net-tools git build-essential
Image

Installing openssh-server

Enter the following command:

Code: Select all

1apt install openssh-server
Image

From a CMD window running as Administrator, enter the following command:

Code: Select all

1ssh localhost
Image

Image

From KiTTY SSH terminal:

Create and save a session called localhost pointing to the host localhost:

Image

Click on “Accept”:

Image

Image

Accessing the Windows file system within Linux

Look at the mountpoint:

Code: Select all

1/mnt/c
Image

Accessing the Linux file system within Windows

From File Explore on Windows, look for the Linux device icon:

Image

Exposing the SSH port on the public IP address of the Windows computer

From a CMD window run as Administrator, enter the following command:

Code: Select all

1ipconfig /all | more
Look through the listing to find the public IP address of the Windows computer:

Image

From a shell on the Linux instance, enter the following command:

Code: Select all

1ifconfig | less
Look through the listing to find the public IP address of the Linux instance:

Image

Opening a firewall exception for port 22/tcp (SSH) inbound on the Windows computer

Click on “New Rule…”:

Image

Select “Port”, click on “Next”:

Image

Select “TCP”. Select “Specify local ports”, enter the value 22. Click Next:

Image

Select “Allow the connection”, click “Next”:

Image

Ensure that “Domain”,”Private”,”Public” are selected. Click “Next”:

Image

For “Name” enter the value: in22tcp

For “Description (Optional):” enter the value: in22tcp

Click “Finish”:

Image

Allowing connections to port 22/tcp of the Linux instance via the public IP address of the Windows Computer

From a CMD window running as Administrator, enter the following commands (subtitute appropriate values for windowsip and wsl2ip:

Code: Select all

1netsh interface portproxy add v4tov4 listenaddress=windowsip listenport=22 connectaddress=wsl2ip connectport=22

Code: Select all

1netsh interface portproxy show all
Image
Post Reply