WSL 2
Install
Section titled “Install”Open terminal as administrator and run
wsl --install -d Ubuntu-20.04#wsl --install -d UbuntuUsefull WSL2 commands
Section titled “Usefull WSL2 commands”wsl --statuswsl --update # Update wsl kernelwsl --shutdownwsl --list -vwsl --list --online # List available distros available for installMap as drive
Section titled “Map as drive”In file explorer you can map WSL distro’s file system with “Map as drive” and using folder
\\wsl$\UbuntuSudoers
Section titled “Sudoers”echo "username ALL=(ALL) NOPASSWD:/usr/bin/apt" | sudo tee /etc/sudoers.d/usernameDisable Ubuntu Pro news in apt
Section titled “Disable Ubuntu Pro news in apt”sudo pro config set apt_news=falsepro config showRemember to upgrade
Section titled “Remember to upgrade”sudo apt updatesudo apt dist-upgradeSetting up zsh
Section titled “Setting up zsh”sudo apt install zsh
# Install oh-my-zshsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install zsh-autosuggestionsgit clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsInstall Docker
Section titled “Install Docker”# Install Dockercurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho "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/nullcat /etc/apt/sources.list.d/docker.listsudo apt-get update -ysudo apt-get install -y docker-ce docker-ce-cli containerd.iosudo usermod -a -G docker $USER
# Start Docker on shell startupecho 'wsl.exe -u root service docker status > /dev/null || wsl.exe -u root service docker start > /dev/null' >> ~/.zshrcInstall Brew & asdf
Section titled “Install Brew & asdf”/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.zshsudo apt-get install build-essentialbrew install gccbrew install asdfbrew install git-delta
# add asdf plugin in your .zshrc# asdf omz plugin did not work correctlyecho 'unset ASDF_DIR' >> ~/.oh-my-zsh/custom/work.zshecho 'source $(brew --prefix asdf)/libexec/asdf.sh' >> ~/.oh-my-zsh/custom/work.zshasdf complaining about shims
Section titled “asdf complaining about shims”After updating asdf/brew, node/yarn stopped working and error shown that shims not found etc. Fix be deleting shims and reshimming:
rm ~/.asdf/shims/*asdf reshimhttps://github.com/asdf-vm/asdf/issues/1115
Setup default editor in Ubuntu
Section titled “Setup default editor in Ubuntu”sudo update-alternatives --config editorWSL2 specific fixes
Section titled “WSL2 specific fixes”Useful tools
Section titled “Useful tools”- asdf
- tldr
- aws-cdk
- awscli
- dotenv-linter
- dprint
- eksctl
- jq
- kubectl
- kubectx
- nodejs
- ripgrep
- shellcheck
- stern
- yarn
- yq
Memory
Section titled “Memory”Edit %USERPROFILE%\.wslconfig file:
[wsl2]memory=8GBguiApplications=falseDNS woes
Section titled “DNS woes”- Disable autogenerated resolv.conf
❯ cat /etc/wsl.conf[network]generateResolvConf = false- Shutdown WSL2
PS C:\Users\username> wsl --shutdown- Create resolv.conf with own DNS & Cloudflare DNS
❯ cat /etc/resolv.confnameserver 192.168.111.111nameserver 1.1.1.1Shell setup
Section titled “Shell setup”mkdir ~/bin
# Misecurl https://github.com/jdx/mise/releases/download/v2024.1.0/mise-v2024.1.0-linux-x64 > ~/bin/misechmod +x ~/bin/mise~/bin/mise version~/bin/mise self-update# Activate in bashecho 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
# ZSHsudo apt install zsh zsh-autosuggestions# Install oh-my-zshsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Azure cli
Section titled “Azure cli”sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyringscurl -sLS https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/keyrings/microsoft.gpgsudo chmod go+r /etc/apt/keyrings/microsoft.gpg
AZ_DIST=$(lsb_release -cs)echo "Types: debURIs: https://packages.microsoft.com/repos/azure-cli/Suites: ${AZ_DIST}Components: mainArchitectures: $(dpkg --print-architecture)Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources
sudo apt updatesudo apt install azure-cli