Skip to content

WSL 2

Open terminal as administrator and run

Terminal window
wsl --install -d Ubuntu-20.04
#wsl --install -d Ubuntu
Terminal window
wsl --status
wsl --update # Update wsl kernel
wsl --shutdown
wsl --list -v
wsl --list --online # List available distros available for install

In file explorer you can map WSL distro’s file system with “Map as drive” and using folder

Terminal window
\\wsl$\Ubuntu
Terminal window
echo "username ALL=(ALL) NOPASSWD:/usr/bin/apt" | sudo tee /etc/sudoers.d/username
Terminal window
sudo pro config set apt_news=false
pro config show
Terminal window
sudo apt update
sudo apt dist-upgrade
Terminal window
sudo apt install zsh
# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Terminal window
# Install Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
cat /etc/apt/sources.list.d/docker.list
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo usermod -a -G docker $USER
# Start Docker on shell startup
echo 'wsl.exe -u root service docker status > /dev/null || wsl.exe -u root service docker start > /dev/null' >> ~/.zshrc
Terminal window
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.oh-my-zsh/custom/work.zsh
sudo apt-get install build-essential
brew install gcc
brew install asdf
brew install git-delta
# add asdf plugin in your .zshrc
# asdf omz plugin did not work correctly
echo 'unset ASDF_DIR' >> ~/.oh-my-zsh/custom/work.zsh
echo 'source $(brew --prefix asdf)/libexec/asdf.sh' >> ~/.oh-my-zsh/custom/work.zsh

After updating asdf/brew, node/yarn stopped working and error shown that shims not found etc. Fix be deleting shims and reshimming:

Terminal window
rm ~/.asdf/shims/*
asdf reshim

https://github.com/asdf-vm/asdf/issues/1115

Terminal window
sudo update-alternatives --config editor
  • asdf
  • tldr
  • aws-cdk
  • awscli
  • dotenv-linter
  • dprint
  • eksctl
  • jq
  • kubectl
  • kubectx
  • nodejs
  • ripgrep
  • shellcheck
  • stern
  • yarn
  • yq

Edit %USERPROFILE%\.wslconfig file:

[wsl2]
memory=8GB
guiApplications=false
  1. Disable autogenerated resolv.conf
Terminal window
cat /etc/wsl.conf
[network]
generateResolvConf = false
  1. Shutdown WSL2
Terminal window
PS C:\Users\username> wsl --shutdown
  1. Create resolv.conf with own DNS & Cloudflare DNS
Terminal window
cat /etc/resolv.conf
nameserver 192.168.111.111
nameserver 1.1.1.1
Terminal window
mkdir ~/bin
# Mise
curl https://github.com/jdx/mise/releases/download/v2024.1.0/mise-v2024.1.0-linux-x64 > ~/bin/mise
chmod +x ~/bin/mise
~/bin/mise version
~/bin/mise self-update
# Activate in bash
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
# ZSH
sudo apt install zsh zsh-autosuggestions
# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Terminal window
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -sLS https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg
AZ_DIST=$(lsb_release -cs)
echo "Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: ${AZ_DIST}
Components: main
Architectures: $(dpkg --print-architecture)
Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources
sudo apt update
sudo apt install azure-cli