Installation
Visit the Microsoft Store and install Ubuntu.
Click get and then wait for the download to complete. You can view the status of the download by clicking the download icon in the top right corner.
Once it has downloaded, click the launch button from the initial ubuntu screen.
Enter a new username and password.
Launch the Ubuntu App to get a command prompt.
USER@HOST:~$ uname -a Linux N-CND1042RH7 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Common Tasks
Mount your windows home folder
$ cd ~ $ ln -s /mnt/c/Users/mehan home
Disable visual and audio bell/beep in WSL on Windows 10
$ vi ~/inputrc
Add the following
set bell-style none
Turn off Command Prompt Sounds
Open up Sound Settings
Scroll down to Advances Sound options and click it.
Set Console Window Host volume to 0
Advanced Tasks
Adding Docker Support
We can add our user to the docker user group by issuing the following command:
$ sudo usermod -aG docker <USER>
Update permissions on docker.sock
$ sudo chmod 666 /var/run/docker.sock
Adding Kubernetes Support
See https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
Install kubectl
# download $ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" #install $ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Adding VPN Support
Record your current nameserver
$ cat /etc/resolf.conf # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.17.192.161
1. cd /etc
2. echo "[network]" | sudo tee wsl.conf
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf
4. wsl --terminate Ubuntu #(Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
6.5 Connect to your vpn
7. In windows cmd, with the vpn connected do:
> ipconfig /all to get the dns primary and secondary.
135.5.25.53
135.239.25.53
8. With the dns primary and secondary . Replace X.X.X.X in the folllowing steps with the primary and secondary DNS ips
9. echo "nameserver X.X.X.X" | sudo tee /etc/resolv.conf (Create resolv.conf and append the line.)
10. echo "nameserver X.X.X.X" | sudo tee -a /etc/resolv.conf (Append the line in resolv.conf)
11. wsl --terminate Ubuntu (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
12. sudo chattr +i /etc/resolv.conf
13. And finally in windows powershell with Administrative rights:
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
References
Reference | URL |
---|---|
Fix DNS resolution in WSL2 | https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6 |