How to install and configure WSL on Windows

How to install and configure WSL on Windows

What is WSL

Quoting a passage from Baidu Encyclopedia:

Windows Subsystem for Linux (WSL for short) is a compatibility layer for running Linux binary executable files (ELF format) natively on Windows 10. It was developed by Microsoft in collaboration with Canonical, with the goal of enabling a pure Ubuntu 14.04 "Trusty Tahr" image to be downloaded and unpacked to the user's local computer, with the tools and utilities in the image running natively on this subsystem.

We simply think of it as a Linux environment installed on Windows. That is the best Linux distribution: Win10 + WSL (funny).

Install WSL

1. Enable or disable Windows features <br /> First, search and open "Enable or disable Windows features" in the search bar, and check the "Windows Subsystem for Linux" item. Only by turning on this setting can WSL be installed normally.

2. Install WSL
Search for Linux in the Microsoft App Store and you will see a series of Linux distributions. Choose the distribution that suits you according to your needs. Here I choose Ubuntu 18.04 LTS. After downloading, start it, wait for the installation to complete, enter the account and password, and we will get a Linux environment.

3. WSL file location
If you want to view other partitions in Linux, WSL mounts other drive letters under /mnt.

If you want to view the WSL file location under Windows, the file location is: C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs.

Configure WSL

1. Change the appearance settings <br /> First, let's change the appearance. Since the color scheme of the WSL session window actually depends on the color scheme in the color tag in the CMD properties, the default one is too ugly, with no highlighted characters and no clarity, which seriously affects development efficiency.

This requires the use of an open source CMD color matching tool: ColorTool

After downloading and unzipping, use CMD to open the unzipped path, and then run the following commands. The CMD interface will change. Choose the one you think looks good.

colortool.exe -b deuteranopia
colortool.exe -b OneHalfDark
colortool.exe -b OneHalfLight
colortool.exe -b solarized_dark
colortool.exe -b solarized_light

Then reopen the Ubuntu window and you will find that the color scheme has also been changed. If you are not satisfied, you can also open the terminal's settings properties interface and fine-tune the font and cursor color, etc. It is recommended to check "Use Ctr+Shift+ C/V as shortcut keys for copy/paste", set the cursor shape to a solid box, and set the font to Consolas.

2. Change source
The default apt source of Ubuntu is a foreign source, which is too slow, so I changed it to Alibaba Cloud's source.

a. First copy the source file to back it up for later recovery:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

b. Check the version information

lsb_release -c

Ubuntu 18.04 LTS is codenamed: bionic

c. Edit source files

sudo vim /etc/apt/sources.list

According to the Ubuntu version number, add the corresponding content:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

Save and exit.

d. Updates and Upgrades

sudo apt-get update
sudo apt-get upgrade

3. Install oh-my-zsh
a. Install zsh

sudo apt-get install zsh

Set the default shell to zsh

chsh -s $(which zsh)

After the configuration is complete, use the following command to check whether the configuration is successful.

echo $SHELL

b. Install oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

or

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

After the installation is complete, reopen the terminal and it will become zsh.

c. Set the ys theme to open the oh-my-zsh configuration file

sudo vim ~/.zshrc

Change the theme color to ys

ZSH_THEME="ys" 

Or if you want to try every theme, just set the theme to "random" (funny).

After saving and exiting, reload the configuration file

source ~/.zshrc

4. Install the syntax highlighting plugin

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

For detailed settings, please refer to the official GitHub documentation](https://github.com/zsh-users/zsh-syntax-highlighting)

Make it effective

source ~/.zshrc

5. Simple configuration of vim
Open the vim configuration file

vim ~/.vimrc

Add the following content

colorscheme ron
:syntax on
filetype on
filetype plugin on
filetype indent on
set sts=4
set shiftwidth=4
set backspace=2
set tabstop=4
set showmode
set nu
set nohlsearch

6. Install JDK

Download the linux-64 bit compressed package from the Oracle official website, unzip it to the /usr/local/jvm/ path, add the following statement to .zshrc, and configure the environment variables

export JAVA_HOME=/usr/local/jvm/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre 
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib 
export PATH=${JAVA_HOME}/bin:$PATH 

Revalidation

source ~/.zshrc

That’s all I can think of for now, and I’ll continue to add new content in the future.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Tutorial on installing Docker in Windows 10 subsystem Ubuntu (WSL) (with pictures and text)

<<:  Installation and configuration tutorial of MySQL 8.0.16 under Win10

>>:  A brief analysis of understanding Vue components from an object-oriented perspective

Recommend

Solution to CSS anchor positioning being blocked by the top fixed navigation bar

Many websites have a navigation bar fixed at the ...

The pitfall of MySQL numeric type auto-increment

When designing table structures, numeric types ar...

Code comment writing standards during web page production

<br />I have summarized the annotation writi...

Detailed explanation of the life cycle of Angular components (Part 2)

Table of contents 1. View hook 1. Things to note ...

MySQL 5.7 installation and configuration tutorial under CentOS7 (YUM)

Installation environment: CentOS7 64-bit, MySQL5....

Practical basic Linux sed command example code

The Linux stream editor is a useful way to run sc...

A few experiences in self-cultivation of artists

As the company's influence grows and its prod...

nginx solves the problem of slow image display and incomplete download

Written in front Recently, a reader told me that ...

Solution to MySQL replication failure caused by disk fullness

Table of contents Case scenario Solving the probl...

Summary of JavaScript JSON.stringify() usage

Table of contents 1. Usage 1. Basic usage 2. The ...

Use overflow: hidden to disable page scrollbars

Copy code The code is as follows: html { overflow...

Detailed explanation of fs module and Path module methods in Node.js

Overview: The filesystem module is a simple wrapp...