Skip to main content

(Reference) Setting Up a Linux Environment Using WSL2

This section introduces how to set up WSL2 on Windows.

WSL2

Run the following command in PowerShell with administrator privileges. After a while, the installation will complete, and you will be prompted to restart your system.

wsl --install

Please check the microsoft's official page for details.

Ubuntu

After restarting, WSL2 will be installed, and Ubuntu will automatically be installed as well. Set your username and password in the Ubuntu setup screen.

UNIX username: your-username
New Password: your-password

Virtual Environment

By completing the steps up to this point, a Linux environment will be created on your Windows machine as shown in the diagram below.

wsl21

You can view the directory of the virtual environment by entering the following path in File Explorer.

\\wsl.localhost\Ubuntu\home\

Clone a Repository

If you clone the repository on the Windows side, Linux will need to access the source code through a hypervisor each time, which makes the process very slow. To avoid this, clone the repository on the Linux side.

Create a working folder in a path like the one below:

\\wsl.localhost\Ubuntu\home\work\

Then clone your repository:

git clone --recursive git@your-repo.git

Footnotes

  1. https://thecodeblogger.com/2020/08/22/understanding-differences-between-wsl-1-and-wsl-2/