People like us who belong to Computer Science industry need something more from our machine. We try to think and implement new ways and alternatives to make things easier for ourselves. We love Linux but we need Windows as well to work with. There are many such applications that do not work on Linux but work on Windows. So, we setup a a Linux distro as a virtual machine and use Windows as our main machine, which is fine. But, we needed some more flexibility and performance. So, Windows introduced Windows Subsystem Linux feature to Windows 10.
Getting started with our installation.

1. Requirements (installing WSL):

  • Windows 10 Build 16215 or later.
  • Windows Server 2019 or later.
  • Check the OS version if it's 32-bit or 64-bit.
  • Windows Subsystem Linux enabled.
To check build version and OS bit version (processor architecture), go to Setting > System > About. 

2. Installing WSL :

Go to Control Panel > Programs > Turn Windows features on or off and enable Windows Subsystem for Linux.



Restart the machine.

3. Requirements (installing WSL2) :

  • Windows 10 Build 18362 or later.
  • Virtual Machine Platform enabled.

4. Installing WSL2 :

Go to Control Panel > Programs > Turn Windows features on or off and enable Virtual Machine Platform.
Check the above image for reference.
Restart the machine.
Next step is to download the Linux kernel update package for WSL2. Go through this link.
To set WSL2 as default version, open Command Prompt as Administrator and  type.
wsl --set-default-version 2

5. Installing a Linux Distro :

Go to Microsoft Store and download any Linux Distro as per usage. I preferred Ubuntu 18.04.
Download the Linux distro and then wait until it installs.
Open the newly installed distro and set it up. It asks for a username and password.
Check for WSL version using this command in PowerShell.
wsl -l -v
If the version shown is 2 then perfect else, upgrade to WSL2 using this command. It takes some time to  process.
wsl --set-version < Distro name - version number > 2

Bonus :

Being a cyber security enthusiast I thought to put some bash commands to setup the distro real quick for penetration testing.

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install python
  • sudo apt-get install python3
  • sudo apt-get install python-pip
  • sudo apt-get install python3-pip
  • sudo apt-get install python-dnspython
  • sudo apt-get install ruby-dev
  • sudo apt-get install golang
  • sudo apt-get install vim
  • sudo apt-get install git (generally pre-installed)
The above commands can be copied and pasted to a file with bash extension .sh and then make it executable using the command.
sudo chmod +x <filename.sh>
Install using command.
sudo bash <filename.sh>

Need to install a feature but don't know exactly what it's named in the repository ? 
For example, if sqlmap needs to be installed, follow the below image.
Use go get <repository destination> command to fetch golang based repositories of the packages.
Use git clone <repository destination> command to fetch repositories from Github.
To execute these installed tools from any directory use this command.
sudo cp <tools or the script name> /usr/bin/

To transfer files from WSL to Windows, simply create a python server using this command.
python -m http.server (python3)
python -m SimpleHTTPServer (python2)
By default the server is created on port 8000.
Use ifconfig command in WSL to check ip address then browse to the link <your ip address>:8000

To do the vice-verse, create the python server on your Windows machine. Enter the command in Command Prompt. Check the ip address in ipconfig.
To access fetch files in WSL, use wget command.
wget http://<your ip address>:<port>/<file destination>


That's all for this post.











Post a Comment

Previous Post Next Post