What is WSL? How to Install Linux on Windows with WSL?
Hello everyone, in this article I will explain how you can install Linux on Windows without making any external downloads or creating a virtual machine.
Without extending our introduction too much, let's look at why we should use WSL or what advantages it has over a virtual machine, and then proceed with the installation.
What is WSL?
WSL is a system that came with Windows 10 and it can be said that it saves us from dual-boot or virtual machines in order to use the Linux operating system on our computer.
WSL was first released by Windows for Windows 10, and thanks to this system we can use certain Linux distributions simultaneously with Windows.
System Requirements
There are two versions of WSL. WSL and WSL2
- For WSL, you need Windows 10 - version 1607 or later.
- For WSL2, you need Windows 10 - version 1903 or later.
With WSL2, file system performance and system call compatibility have been improved.
Linux Distributions Supported on Microsoft Store
- Ubuntu
- Kali Linux
- Fedora Remix
- Open Suse
- Pengwin
Why WSL?
Normally, we had a few options to use a Linux operating system and these were;
- Uninstalling Windows and directly installing Linux.
- Installing Linux alongside Windows and choosing one of the two operating systems at startup.
- Installing Linux on Windows with the help of virtual machine software.
We have essentially continued our lives until today with the above options, but almost all of them had certain difficulties and, although not very important for regular users, they were significant losses for developers, I can say.
When we uninstall Windows and install Linux directly, we could not benefit from many programs and development environments on Windows.
When we installed Linux alongside Windows, switching between the two operating systems caused a lot of time loss, and sometimes it was a hassle when there was a file we needed to affect on Windows.
Running a Linux distribution in a virtual machine is a much more costly way compared to other methods. (Performance loss, high RAM requirement, etc..)
Although WSL is not as performant as installing Linux directly on your computer, it is much more performant compared to installing it on a virtual machine. And since the Linux version installed with WSL can access Windows files easily, it actually makes our job much easier. For this reason alone, Linux can be installed on Windows with WSL.
How to Install Linux on Windows with WSL?
Enabling Windows Features
For installation, first there are some features you need to enable from the "Turn Windows features on or off" section. These are;
- Windows Subsystem for Linux
- Virtual Machine Platform
To start the setup, check the two features I mentioned above and then click the "OK" button.
The necessary features will be installed automatically by Windows. After the required features are installed, I recommend you to restart your computer. In fact, after the installation, Windows will ask whether to restart.
Note: You need to restart for the features to be active after enabling them.
Installing the Linux Distribution
After this step, let's download any Linux distribution you want from the Microsoft Store.
Since I want to use Ubuntu, I'm downloading the Ubuntu version. (It's about 450 MB.)
After the download is complete, click the "Launch" button to start Ubuntu.
After it opens, a console screen will appear.
If you get a kernel update error, you will need to update the WSL2 kernel.
WSL2 Kernel Update / Installation Process
Click the link below and go to the website.
Download the latest version of WSL2 from the link under "Download the latest package" option.
After the file is downloaded, double click to install, click the "Next" button and grant administrator permission if asked. When the installation is complete, click the "Finish" button.
The installation is now complete and we can open our Ubuntu version without errors. Now when you open, the installation will start without giving an error.
After the loading screen finishes, it will ask you to create a username and password.
When you see a screen like above, the installation is complete.
Some Linux Commands
We can use a few commands to check some features of the Linux version we have installed.
Finding Out Which Directory You Are In
To find out which directory you are in
You can use the command.
Learning the Version of the Operating System
To learn the version of your operating system
You can use the command.
Checking Internet Connection
To check whether your installed Linux version is connected to the internet
You can use this command and if no issue occurs and the ping is successful, then it means you are connected to the internet.
Updating the Linux System
To update the Linux version you have installed
You can use this command.
Note: This command may differ depending on your installed Linux distribution.
WSL Management
For WSL management, first, we need to open the Command Prompt (cmd) as administrator.
Getting Information About WSL Status
To get information about WSL in cmd
We run the command. This will show us the running operating system, its status, and the WSL version.
Changing the WSL Version
If you want to change the WSL Version
wsl – -set-version Ubuntu (Your operating system name) x (WSL version)
Just enter the command.
Shutting Down the Operating System
If you want to shut down the operating system running on WSL
Just enter the command.
Adding a Graphical User Interface
If you wish, you can add a graphical user interface (GUI) to the operating system you downloaded.
To use the operating system in GUI form, you can install a GUI like "xfce4" in the Ubuntu terminal.
Installing XFCE4 Interface
To install the interface
Running the command will be sufficient. (Of course, during installation, do not forget to confirm by saying "Y" when it prompts you with "Do you want to install? (Y/n)" )
This process might take a while as many packages need to be installed.
Please do not close your terminal or computer during the installation.
Note: If you get any errors after installation, try again with the code below.
sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils
Connecting with Remote Desktop
You can connect to the operating system you have installed via the "Remote Desktop Connection" program found in Windows and use it just like a normal Linux. But of course, for this, we need to perform a few more installations.
Install XDRP
First, we need to install the package needed to access our operating system (Linux) from Windows. For this
We use the command. Once the installation is complete
Starting XDRP
sudo /etc/init.d/xrdp start
With this command, we start xrdp and now we can connect to the interface from our Windows device using the "Remote Desktop Connection" program.
Getting the IP Address to Connect
To connect, we need to find out the IP address of the operating system we have installed. For this
We use the command and grab the "inet" address from the lines that appear. Now we can use this to connect to the device.
Remote Desktop Connection
We can now connect to remote desktop using the IP address, username, and password we obtained in the previous step.
We connect by entering the inet0 address into the Remote Desktop Connection program
After connecting, we log in with the user account we created at the beginning.
Yorum Gönder