wsl安装ubuntu,
wsl安装ubuntu,
WSL
wsl --install
用管理员打开powershell
启用适用于 Linux 的 Windows 子系统
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
重启
安装这个(也有可能你安装过了)
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
继续打开powershell(管理员)
wsl --set-default-version 2
安装
然后
wsl -l -o
列出可以安装的系统
比如安装ubuntu18
wsl --install -d Ubuntu-18.04
然后设置账号密码
换源
https://blog.csdn.net/qq_39942341/article/details/120394844
转移到其他的盘/备份
比如说,转移到d:\ubuntu
# 备份 wsl --export Ubuntu-18.04 d:\ubuntu18.04.tar # 还原 wsl --unregister Ubuntu-18.04 md d:\ubuntu wsl --import Ubuntu-18.04 d:\ubuntu\Ubuntu-18.04 d:\ubuntu18.04.tar --version 2 ubuntu1804 config --default-user test del d:\ubuntu18.04.tar
其中test是你当时设置的用户名
重启方法
net stop LxssManager //停止 net start LxssManager //启动
启用systemd
sudo apt install -y git cd ~ git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git cd ubuntu-wsl2-systemd-script/ bash ubuntu-wsl2-systemd-script.sh
重启
如果你有装zsh
可能每次要
exec bash exec zsh
然后才可以用systemctl了
安装桌面
xfce4
貌似要systemd(或者你失败了在来装也可以)
sudo apt install -y lightdm
如果出现了这个画面,就选lightdm
//没出现就没出现吧
sudo apt install -y xfce4 xrdp
然后
sudo dpkg-reconfigure lightdm
如果跳那个界面,就选lightdm
然后改端口
sudo vim /etc/xrdp/xrdp.ini
port=3389改成port=3390(或者其他端口,貌似3389连不上)
sudo vim ~/.xsession
然后添加xfce4-session
然后重启(指前面那种重启)
sudo /etc/init.d/xrdp start
然后就可以了
ubuntu-desktop
先启用systemd
然后
sudo apt install -y ubuntu-desktop xrdp gnome-software gnome-tweaks gnome-shell-extensions
sudo systemctl status xrdp sudo adduser xrdp ssl-cert sudo systemctl enable xrdp sudo systemctl restart xrdp
接着修改
sudo vim /etc/xrdp/xrdp.ini
这里port=3389改成port=3390(或者其他端口,3389好像连不上)
接着启用刚刚的端口
sudo ufw allow 3390
修改
sudo vim /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
添加
[Allow Colord all Users] Identity=unix-user:* Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile ResultAny=no ResultInactive=no ResultActive=yes
修改
sudo vim /etc/polkit-1/localauthority/50-local.d/46-allow-packagekit.pkla
添加
[Allow Refresh Repository all Users] Identity=unix-user:* Action=org.freedesktop.packagekit.system-sources-refresh ResultAny=no ResultInactive=no ResultActive=yes
参考(https://blog.csdn.net/wu_weijie/article/details/108481456)
然后重启
sudo systemctl restart xrdp
就可以远程了
(有一个没解决的问题,就是你每一次重启,都要执行这个命令,不然就远程不了)
ssh
sudo apt purge -y openssh-server sudo apt install -y openssh-server sudo systemctl enable ssh
接着
sudo vim /etc/pam.d/sshd
把这一行注释了
重启
sudo systemctl start ssh
(有一个没解决的问题,就是你每一次重启,都要执行这个命令,不然就远程不了)
然后就可以用xshell或者其他工具连接了
评论暂时关闭