WSL - install visual interface environment

1, Install desktop

After installing WSL in Win10, you must miss the intuitive operation of Ubuntu visual interface.
To install the desktop environment in WSL, two major tasks are required: installing VcXsrv in Win10 and Ubuntu desktop in WSL

2, Install VcXsrv

Download and install VcXsrv. After installation, the XLaunch shortcut will appear on the desktop

3, Install Ubuntu desktop

After installing VcXsrv in Windows system, start to install Ubuntu desktop plug-in through the command line in WSL. The steps are as follows
(1) Determine the source of your Ubuntu system
Ubuntu's native source is relatively slow to access in China, so I choose to replace it with Ali's software source; Alibaba cloud's Ubuntu image address is: https://developer.aliyun.com/...

(2) Manually modify the configuration file
Open / etc / apt / sources. In a familiar editor list. Take Ubuntu 18 04 as an example, replace the contents in the file with the following contents:

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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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

(3) Update the address of the acquired image after the replacement is completed

sudo apt-get update && sudo apt-get upgrade

(4) Installing desktop components will take some time

echo "y"|sudo apt-get install ubuntu-desktop unity compizconfig-settings-manager

(5) Configuring dbus to avoid errors

dpkg-reconfigure dbus && service dbus restart

If the permission denied error occurs, you can perform the following operations to solve it:

On the command line, enter:
sudo passwd
 The system prompts for the password and confirms
su root
 Enter the password again to confirm;
At this time, you will find that before the command you enter $Become#To prove that the current user has obtained root permission

4, Configure desktop

After the required components are downloaded, you can start the following operations:
(1) Configure desktop style
Open the XLaunch icon on the Windows desktop, select One Large window or One window without titlebar, and then default all the way. Finally, you will see a pure black interface
(2) Configure the X Server command in the wsl window

export DISPLAY=Your native IP address:0

(3) Execute the following command and switch to the VcXsrv window

sudo ccsm

Set the desktop environment according to the following figure, and exit after setting; In case of conflict, ignore the conflict directly:

(4) Switch to Ubuntu Bash, execute the following command and switch back to VcXsrv to see the effect

sudo compiz

5, Install Chinese support and configure profile file

Open another terminal on WSL and execute the following command to install Chinese support (if the current user is not root, add sudo before the command)

apt-get -y install language-pack-zh-hans

Add the following environment variables to the / etc/profile file

export DISPLAY=localhost:0

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8

Reload profile

source /etc/profile

Complete locale again

sudo locale-gen

If you need to start the desktop environment with other users, you must reconfigure ccsm and other components. Of course, we can also copy the configured configuration file to other accounts by copying the. cache folder under the user directory (cd ~) of the configured desktop environment to other user directories

Keywords: wsl2

Added by DaPrince on Fri, 31 Dec 2021 14:06:04 +0200