WSL setup

Setup WSL on Windows

Jacob Xie published on
3 min, 509 words

Categories: Doc

WSL and Ubuntu download

One line command: wsl --install.

For futher detailed info, visit the official documentation.

Install Windows Terminal

Please follow this step.

Move Ubuntu to another driver

This is an optional step, in case of C driver space insufficient (make sure you have already create directories as following):

wsl --export Ubuntu-20.04 d:\tmp\ubuntu.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 d:\wsl\Ubuntu-20.04 d:\tmp\ubuntu.tar

Modify Windows settings.json

To modify Ubuntu's starting directory, we can open Windows terminal, and you'll see Open JSON file button, click it and add a new line called startingDirectory as below:

    "commandline": "wsl ~ -d Ubuntu",
    "hidden": false,
    "name": "Ubuntu",
    "source": "Windows.Terminal.Wsl",
    "startingDirectory": "~"

Setup wsl.conf

  1. Create a new file called wsl.conf:

    sudo vim /etc/wsl.conf
  2. Inside your file (please modify the username):

    # Set default user, otherwise sign as root
    # Let’s enable extra metadata options by default
    enabled = true
    root = /mnt/
    options = "metadata,umask=22,fmask=11"
    mountFsTab = false
    #Let’s enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
    generateHosts = true
    generateResolvConf = true
    #All windows program shoulbe be normally run in wsl. great!
    enable = true
    appendWindowsPath = true
  3. Save your file and grant permission:

    sudo chmod -R 775 /etc/wsl.conf

New user

  1. Add user:

    sudo adduser jacob

    remove user:

    sudo deluser jacob
  2. Update sudoers

    sudo -i
    vim /etc/sudoers

    add a new line:

    jacob ALL=(ALL) ALL

Setup Git

git config --global <Your name>

git config --global <Your email>

If the following error occurred:

Warning: Permanently added ',XX.XXX.XXX.XXX' (RSA) to the list of known hosts.

Open the hosts file:

vim /etc/hosts

Add add the line:


Generate SSH key and add to GitHub

Execute the following command:

ssh-keygen -t rsa

Copy the public key to your GitHub account:

cat ~/.ssh/

Issues may occur

Setup Github Cli (Debian/Ubuntu)

A shortcut:

sudo apt-key adv --keyserver --recv-key C99B11DEB97541F0
sudo apt-add-repository
sudo apt update
sudo apt install gh

Then authentication (follow up the indication provided by gh):

gh auth login

Visit Github Token page and generate a new token. Copy this token to the terminal when ? Paste your authentication token: occurs.

Setup Github Cli (CentOS)

  1. Install DNF:

    sudo yum install epel-release
    sudo yum install dnf
    dnf --version
  2. Using DNF to install gh:

    sudo dnf install 'dnf-command(config-manager)'
    sudo dnf config-manager --add-repo
    sudo dnf install gh
  3. Authentication:

    gh auth login