wsl2+x410 搭建win10下Linux开发环境
🚞

wsl2+x410 搭建win10下Linux开发环境

Tags
docker
wsl2
Linux
Ubuntu

WSL2的安装

按照官方文档按照,不得不说阅读微软的文档是真的舒服
最后选择 ubuntu 20.04的发行版本即可,后续操作都是以这个发行版本为主
 

WSL2环境配置

首次启动Ubuntu会有一个初始化过程,需要几分钟,然后创建一个Ubuntu账号,使用sudo passwd 设置root用户的密码,之后切换到root用户
 

换源

一般来说装完Linux系统第一件事就是换源,毕竟国内访问外网的网速感人,这里采用的是清华源,可以通过下面的地址获取清华源的配置
选择对应版本的20.04的源
cd /etc/apt/
# 备份
mv sources.list sources.list.def
sudo vim sources.list
# INSERT:::粘贴清华源的配置
sudo apt-get update
 

安装Docker

两种方式
  1. Docker Desktop+WSL2 运行 Docker
    1. Docker DesktopDocker CEDocker ComposeKubernets 等软件整合在了一起进行安装,省去了一一安装的烦恼。Docker Daemon 由于是安装在宿主机上的,因此可以直接使用宿主机的网卡信息对容器进行访问。下载安装Docker Desktop运行 Docker,可以让你在Windows中方便的管理配置Docker
      傻瓜式安装即可!
      配置Docker Desktop, 使用 WSL2运行Docker engine
      notion image
  1. WSL2子系统中安装Docker
该方式是利用 Windows Hyper-v 将Docker装在子系统虚拟机中的,但该方式装的虚拟机启动、读写性能方面要比使用Virtual Box、 VM的方式更好。
 

x410配置图形化界面

 
x410是付费的,当然也有免费的VcXsrv 功能没有x410强大
Linux Xfce图形界面
sudo apt update && sudo apt -y upgrade
sudo apt install xfce4 xfce4-terminal
新建windows批处理脚本start-ubuntu-xfce-desktop.bat放到c盘 目录wls2scripts目录下
start /B x410.exe /desktop
ubuntu2004.exe run "if [ -z \"$(pidof xfce4-session)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; xfce4-session; pkill '(gpg|ssh)-agent'; taskkill.exe /IM x410.exe; fi;"
新增bat-launcher.vbs
If WScript.Arguments.Count <= 0 Then
    WScript.Quit
End If	

bat = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & WScript.Arguments(0) & ".bat"
arg = ""

If WScript.Arguments.Count > 1 Then
    arg = WScript.Arguments(1)
End If

CreateObject("WScript.Shell").Run """" & bat & """ """ & arg & """", 0, False
回到桌面,右键新增快捷方式
notion image
wscript.exe "C:\wsl\bat-launcher.vbs" "start-ubuntu-xfce-desktop" 将此段命令作为位置输出
notion image
第二个字符内是bat文件的名称(不需要后缀)
网上找个icon ,替换默认的很丑的图标
最终效果
最终效果
安装中文输入法
apt-get install ibus ibus-pinyin 
#安装ibus

im-config
#配置输入法
#选择ibus

ibus-setup
#设置ibus输入法

input-method->add->chinese
#设置完成
#win+空格切换输入法
设置开机自启动
notion image
notion image
ibus-daemon -r -d 以后台形式启动输入法

X410 Linux win10混合模式

这个功能是让Linux软件直接在win的桌面打开,批处理文件改下参数即可
start /B x410.exe /desktop 改成start /B x410.exe /wm
notion image
 

开发软件安装

edge安装
## Setup
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
sudo rm microsoft.gpg
## Install
sudo apt update
sudo apt install microsoft-edge-dev

Loading Comments...