Use WSL (Windows Subsystem for Linux) on Windows instance
WSL (Windows Subsystem for Linux) enables developers to easily use a Linux environment on Windows computers or Windows-based cloud instances. With WSL, you can install Linux distributions (e.g., Ubuntu, OpenSUSE, Kali, Debian, Arch Linux) and run Linux applications, utilities, and Bash command-line tools without additional virtual machine setup.
- Estimated time: 30 minutes
- User environment
- Recommended OS: Windows Server 2019, Windows Server 2022
- Region: kr-central-2
- Supported WSL version: WSL 1
WSL 2 requires nested virtualization, which needs direct access to hardware. Currently, KakaoCloud's VM environment does not support direct hardware access, so WSL 2 is not supported.
For VM instances running Windows Server 2019, refer to the Windows Subsystem for Linux documentation for configuration. Then follow Step 1. Install WSL 1 to enable WSL 1.
About this scenario
This scenario introduces how to implement WSL (Windows Subsystem for Linux) using a Windows instance created with KakaoCloud's Windows image.
Key topics include:
- Configure a Windows instance using KakaoCloud VM service
- Install WSL on Windows instance
- Install the default Ubuntu distribution
- Use Bash command-line tools with the installed distribution
Before you start
You need to configure a VPC, subnet, and security group beforehand.
1. Create VPC and subnet
Before creating an instance, you need a VPC and subnet where the instance will reside.
If you don’t have them, refer to the Create VPC and Create subnet documents to create them.
2. Create security group
Add inbound rules to the security group.
If you don’t have a security group, refer to the Create security group document to create one and add inbound rules.
Click the button below to check your current public IP.
CIDR | Protocol | Port | Role |
---|---|---|---|
{Your public IP}/32 | TCP | 3389 | RDP |
Getting started
1. Configure Windows instance
In this step, you will create a Windows-based instance using KakaoCloud's Virtual Machine service, set up basic network configurations, and enable remote access.
Step 1. Create Windows instance
Create a Windows-based instance using KakaoCloud's Virtual Machine service. A Windows instance provides a powerful platform in the cloud environment to run various applications and services based on the Windows operating system.
-
Access the KakaoCloud console and complete the prerequisites.
-
Navigate to Beyond Compute Service > Virtual Machine.
-
In the Instance menu, click the [Create instance] button.
-
In Create instance, configure the VM instance with the following settings, then click the [Create] button.
Item Setting Basic information - Name: Specify freely
- Count: 1Image Select Windows Server 2022 from the Basic tab Instance type m2a.large Volume Root volume: 50GB or more Key pair Private key
Format:.pem
, create new or use existingNetwork - VPC: Select the pre-created VPC from prerequisites
- Subnet: Select the pre-created subnet from prerequisites
- Security group: Select the security group created earlier
- Network interface: New interface
- IP allocation method: Auto-assigned
Step 2. Associate public IP
Associate a public IP with the created VM instance to enable communication with external networks.
- In the KakaoCloud console, select Beyond Compute Service > Virtual Machine.
- Click the more options icon for the created Windows instance and select Associate public IP.
- In the popup, select Create new public IP and assign it automatically, then click [Confirm].
- Verify the public IP in the Default public IP column.
Step 3. Access via RDP
Use RDP (Remote Desktop Protocol) to connect to the Windows instance by referring to Connect to Windows instance.
- RDP is a protocol that allows remote desktop connections to other computers or servers.
2. Install and configure WSL
This step explains how to install WSL 1 (Windows Subsystem for Linux) on a Windows instance.
Step 1. Install WSL 1
By default, WSL 2 is installed, but in the KakaoCloud VM environment, WSL 1 is supported. WSL 1 allows seamless integration between Windows and Linux environments, providing a lightweight and efficient Linux environment.
-
Open Start and search for PowerShell or cmd, then click to run it.
-
By default, WSL 2 is installed. Enable WSL 1 using the
--enable-wsl1
option.Install WSLwsl --install --enable-wsl1 --no-launch
ResultInstalling: Virtual Machine Platform
[=========================71.2%========== ]
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: Windows Subsystem for Linux
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
The requested operation completed successfully. Changes will take effect after restarting the system.
Step 2. Restart VM instance
-
Restart the Windows instance.
Reboot instanceshutdown -r -t 0
-
Double-click Saves PCs in the Windows App application to access the device.
Step 3. Set WSL 1 as default version
Run the following command to set WSL 1 as the default version in WSL:
wsl --set-default-version 1
Operation completed successfully.
Step 4. Install default Ubuntu distribution
Run the following command to install the default Ubuntu distribution:
wsl --install
Ubuntu has been installed.
Starting Ubuntu...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: ubuntu
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 4.4.0-20348-Microsoft x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This message is shown once a day. To disable it please create the
/home/ubuntu/.hushlogin file.
ubuntu@172-16-0-35:~$
Step 5. Verify installation
Verify WSL installation
After completing the installation, run the following command to verify that WSL is functioning correctly. If Ubuntu appears in the list and the VERSION
value is set to 1
, the installation was successful.
wsl --list --verbose
NAME STATE VERSION
* Ubuntu Running 1
You are now ready to use various command-line tools and applications in the Linux environment.
For more details about WSL, refer to the official WSL documentation.