Skip to content

Instantly share code, notes, and snippets.

@rfaita
Last active October 1, 2023 04:03
Show Gist options
  • Save rfaita/17c65d17b6011791369c5ee9023a16c9 to your computer and use it in GitHub Desktop.
Save rfaita/17c65d17b6011791369c5ee9023a16c9 to your computer and use it in GitHub Desktop.
Installing WSL2 on Windows 10

Install and configure WSL2 on windows 10

Install WSL2

Using the following link here install the WSL 2 on your windows 10.

Install X-Server

VcXsrv seems to the best choice for X-Server in Windows

After installation, use the following command to create a new desktop shortcut. Add the following command in the properties → shortcut →target

"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto 

Use below command in command prompt to verify it. (execute it on a Windows Shell with Admin Priv)

netstat -abno|findstr 6000

##Install Terminator in Bash

Open Ubuntu and install terminator

sudo apt-get update
sudo apt-get install terminator

With the X-Server running execute the following command, to validate the terminator:

DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 terminator &

If you see the terminator window, then we are successful with the initial setup.

But to launch a window first we need to run XServer then open a Ubuntu window and launch terminator using a command. This all seems too much for launching a terminal.

So in the next section, we will see how to automate these steps.

Add Xserver to Startup Program

Using Window(KEY)+R, execute the following command:

shell:startup

Copy the shortcut created above to init the X-Server inside of this folder.

VBS script to start Terminator

Create a folder in your windows home directory and create the following file: startTerminator.vbs

Content:

args = "-c" & " -l " & """DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0

Create a new shorcut with the following command:

C:\Windows\System32\wscript.exe C:\Users\<YOUR_USER>\linux\terminator\startTerminator.vbs

You can download a nice ICON from here.

Limiting memory to WSL2

Create a .wslconfig file inside of directory: %UserProfile%

Content:

[wsl2]
memory=5GB
swap=0
localhostForwarding=true

Last recommendations

  • Install ASDF
  • Install CODE on linux
  • Install Docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment