This is the 13th day of my participation in the August More Text Challenge

Preface

WSL (Windows Subsystem for Linux) is the Windows Subsystem for Linux.

Since Win10 has a Linux subsystem (WSL), I will directly put the computer on the VMware virtual machine software uninstall.

WSL experience is good, who uses who knows!!

Plus Windows Terminal, the latest Terminal, through some configuration can make the Terminal very easy to use and comfortable eye, more conducive to Linux programming.

This article contains a complete tutorial to use Linux under Win10, including installation and environment configuration.

The tutorial is detailed enough, xiaobai can understand, I hope to give a praise 😘 put a final result:

WSL installation

Win10 version needs to be above 1903, my version is 20H2.

You can open win + R to run, enter Winver to view the version number.

  1. Open PowerShell as an administrator and type:

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    Copy the code
  2. After typing, restart your computer to complete the WSL installation and update to WSL 2.

  3. After the restart, download the WSL2 Linux kernel update package for X64 computers and install it.

  4. Set WSL 2 to the default version:

    wsl --set-default-version 2
    Copy the code
  5. Download the Linux distribution from the Microsoft Store, in this case Ubuntu 20.04 LTS.

  6. Open it after downloading. Wait for a while to open it for the first time. Then we set up the user name and password.

  7. Once the username and password are created, the account will be the default user for the distribution and will be automatically logged in at startup. Is considered a Linux administrator, capable of running sudo administrative commands.

Attached are links to all distributions

  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • Packages Leap of 15.1
  • SUSE Linux Enterprise Server 12 SP5
  • SUSE Linux Enterprise Server 15 SP1
  • Kali Linux
  • Debian GNU/Linux
  • Fedora Remix for WSL
  • Pengwin
  • Pengwin Enterprise
  • Alpine WSL

Ubuntu configuration

  1. To avoid entering a password every time sudo is required, configure visudo:

    sudo visudo
    Copy the code
  2. Add a line at the end of the file (change to your own user name), Ctrl + S to save, Ctrl + X to exit.

    username ALL=(ALL) NOPASSWD: ALL
    Copy the code

Configure a domestic mirror source

To speed up the download of software

  1. Back up the original source:

    cd. /.. /.. /.. /.. /..Back to the root directory
    cd /etc/apt/
    cp sources.list sources.list.bak
    
    If you cannot copy, go to superuser and try again
    sudo su
    Copy the code
  2. Modify source contents:

    sudo vim sources.list
    Copy the code
  3. Delete all of them and modify them to the image of Ali Cloud:

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    Copy the code
  4. Update software list:

    sudo apt update
    sudo apt upgrade
    Copy the code

vim

In case someone won’t use it, briefly say how to write and save:

  1. According to theICan edit, copy and paste good (old CV engineer).
  2. Press Esc to exit the edit and enter:wqSave and exit vim.

Configuring the Python Environment

  1. Installation:

    sudo apt install python3
    sudo apt install python3-pip
    Copy the code
  2. Replace the PIP source:

    cd ~
    mkdir .pip
    Copy the code
  3. Create and edit pip.conf:

    sudo vim ~/.pip/pip.conf
    Copy the code
  4. To:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ 
    [install]
    trusted-host = pypi.tuna.tsinghua.edu.cn
    Copy the code
  5. Changing the default Python version to PYTHon3 is too cumbersome to type python3 each time:

    Delete the original soft link, if not directly created
    sudo rm /usr/bin/python
    sudo rm /usr/bin/pip
    
    # Create a soft link
    sudo ln -s /usr/bin/python3 /usr/bin/python
    sudo ln -s /usr/bin/pip3 /usr/bin/pip
    Copy the code
  6. Now type Python to enter the Python3 environment directly


In the next part, we will update how to create a perfect Terminal experience for Windows 10 by using Windows Terminal + Oh-my-zsh + p10K + zsh-plugins. If you are interested, click on it

Finally ask a thumbs up 👍👍 if there are any questions can comment to communicate with each other.

I am Mancuoj, more interesting articles: Mancuoj personal homepage – article – Nuggets (juejin. Cn)