catalogs
preamble
Here is why we should install the desktop version of Ubuntu under the Windows subsystem, some people may ask if the virtual machine does not smell good, dual-system does not smell good? Tossing dual system without noticing the original environment of the screwed up, the installation of virtual machines, then may be due to computer hardware limitations resulting in a virtual machine is very lagging can not be used properly, so here is only for the two pain do not want to go through the above another method.
I. Installing a Linux Subsystem on Windows
Prerequisite.
-
The windows machine needs to support virtualization and needs to have virtualization turned on in the BIOS as WSL2 is hyper-V based.
Check to see if virtualization is turned on
hold downWindows+R
importationcmd
Open the command line and typesysteminfo
You can see the following words, which means that the computer already supports virtualization and you can continue the installation
Hyper-V Requirements: VM Monitor Mode Extension: Yes Virtualization enabled in firmware: Yes Secondary Address Translation: Yes Data Execution Protection Available: Yes
-
Whether it is Windows 10 or Windows 11, the Windows used is the latest version, if it is not the latest version, the
set up
–Windows Update
Update the system to the latest version in the
Installation steps
1. Enable developer mode
inset up
Search for “Developer Settings” and open it;
show (a ticket)Developer model
and clickis
If you want to use it, you have to turn on the developer mode successfully.
2. Enable “Windows subsystems for Linux”.
locatecontrol panel
–Programs and functions
–Enabling or Disabling Windows Features
If you want to change the “Windows Subsystems for Linux”, check “Windows Subsystems for Linux”, and then clickrecognize
You can see the following response from the computer, which is processing the changes.
At this point, clickImmediate restart
Just wait for your computer to reboot and finish.
3. Installation of Linux distributions
Official Microsoft Documentation
3.1 Upgrading the WSL kernel
Microsoft Official Documentation – Manual Installation Procedures for Older WSL Versions
Download the Linux kernel update package.WSL2 Linux kernel update package for x64 computers;
Double-click to run the update package you just downloaded with the suffix.msi
If the following installation screen appears, clicknext
Proceed with the installation until the Installation Success screen appears.
3.2 Enabling the Virtual Machine Function
Before installing WSL 2, the Virtual Machine Platform optional feature must be enabled. The computer needs to be virtualized to use this feature.
Open as administratorPowerShell
And run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
At this point, you need to restart your computer and wait for it to finish restarting.
3.3 Setting WSL 2 as the Default Version
show (a ticket)PowerShell
, then run the following command when installing a new Linux distribution to set WSL 2 as the default version:
wsl --set-default-version 2
3.4 Installing Ubuntu 20.04
show (a ticket)Microsoft Store
Search for “Ubuntu” and selectUbuntu20.04 LTS
Click Install until the download is complete;
At this point we can add thecommencement
See the Ubuntu 20.04 icon in the menu:
Double-click to open can see the information of the registered account, according to personal habits enter the account name and password can be.
After the password is entered, you can see the information about Ubuntu 20.04, and at this point the installation of Ubuntu 20.04 under the Windows subsystem is complete.
At this point it is possible to set thethis computer
see inLinux
If you open it, you can see Ubuntu’s files, and subsequent file operations with Ubuntu can be performed from here.
Second, install the desktop environment on the subsystem Ubuntu 20.04
1. Replacement of software sources
Because Ubuntu’s default software source in foreign countries, sometimes after the download software may cause lag, here we replace the domestic AliCloud source, other domestic sources can also be.
double-click to openUbuntu20.04 LTS
icon, at the command line type
# Backup original software source
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# Editing software sources
sudo nano /etc/apt/sources.list
Replace the original with
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
as shown below, and then pressCtrl + O
Save and pressCtrl + X
Exit edit mode.
2. Updating and upgrading software
Execute the following commands in sequence from the Ubuntu command line:
# Update software sources
sudo apt-get update -y
# Upgrade all software
sudo apt-get upgrade -y
3. Install the gnome desktop environment
The distributed version of Ubuntu installed under the Windows subsystem does not come with a desktop environment by default, in order to be able to use the desktop environment, we need to install it manually. There are desktop environments such as xfce4, gnome, etc. Here we choose the most classic gnome desktop environment, which is similar to the desktop environment of the official version of Ubuntu.
Execute the following commands in sequence from the Ubuntu command line:
# Install the gnome desktop environment
sudo apt-get install ubuntu-desktop
# Installation of related tools
sudo apt-get install gnome-tweak-tool
4. Install systemctl
Distributed Ubuntu installed under the Windows subsystem does not support the systemctl command by default, however systemctl is very important in native Ubuntu and is installed manually here.
Execute the following commands in sequence from the Ubuntu command line:
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
attention (heed)
: Here may be antivirus software will appear a warning, you need to allow all the operations of the program or first close the antivirus software, when you see the following picture shown on behalf of the installation is successful.
At this point you need to restart the WSL service and open it in administrator modePowerShell
Implementation
# Discontinued services
net stop LxssManager
# Start the service
net start LxssManager
5. Installation of remote control software xrdp
Every time we double-click on an openUbuntu20.04 LTS
The icons are all command line terminals and you can’t see the desktop environment, so you need to install remote control software in Ubuntu and then use Windows’ ownmstsc
tool for the purpose of visualizing and operating Ubuntu.
Execute the install install command from the Ubuntu command line:
# Install the xrdp remote control service
sudo apt-get install xrdp
Change the port from 3389 to 3390, as the default port 3389 was previously reserved for the ubuntu shell
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
Configure the startup session, otherwise the remote desktop login will flash directly after entering the password
echo "gnome-session" > ~/.xsession
Restart the xrdp service
sudo systemctl restart xrdp
At this point you can check the xrdp service status
sudo systemctl status xrdp
As shown, there are greenrunningRepresents successful operation of the service.
III. Booting the desktop version of Ubuntu from Windows
hold downWindows+ R
In the run box, typemstsc
and then press enter
calculator
importationlocalhost:3390
and then press enter
Notes:
here are:
for the English state; where it can be entered in theDisplay Options
Save this connection to your desktop in the “Save to Desktop” section to make it easier to open it later.
optionis
Enter your account and password here and click theOK
After the previous step there may be a brief black screen, do not be afraid! This is not the configuration is not successful, wait a little while you can see the following picture, so that the desktop environment has been successfully configured and can be accessed normally!