天天看點

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

修改root密碼

windows子系統(WSL)root或者普通使用者密碼忘記,如何修改?

http://www.mamicode.com/info-detail-2933442.html

打開CMD或PowerShell,輸入

ubuntu config --default-user root

,修改ubuntu系統預設使用者為root,再打開bash輸入passwd root修改密碼。

注: 可以先在bash中輸入lsb_release -a檢視ubuntu版本,根據他人的說法,18.04版本的需要輸入的指令是ubuntu1804 config --default-user root,kali版本需要輸入的是kali config --default-user root。也可以輸入ub後按下tab鍵補全檢視自己應當輸入的是ubuntu還是ubuntu1804之類的。

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

重新開機 Windows 10 子系統(WSL) ubuntu

直接關閉視窗,或者 Windows PowerShell(管理者) ,執行指令:

#Windows PowerShell(管理者模式) 
net stop LxssManager
net start LxssManager
           

host 說明

直接修改 Windows host 即可映射

# C:\Windows\System32\drivers\etc\hosts
127.0.0.1 larabbs.test
           

可視化界面

安裝xfce4失敗了 也啟動不了(Ubuntu20.04)

Ubuntu18可以 但是使用mobaxterm不能選擇指定WSL,直接啟動了Ubuntu20.04,想指定啟動目錄但是隐藏了

C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2020.824.0_x64__79rhkp1fndgsc
           

在指令行指定預設版本

wsl -s Ubuntu-18.04
           
WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

進去後檢視系統版本

lsb_release -a
           

配置mobaxterm

MobaXterm

http://www.pc6.com/softview/SoftView_649420.html

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

啟動後會有一個額外的黑窗

WSL安裝xfce desktop

sudo apt-get install xfce4-terminal
sudo apt-get install xfce4
           

配置檔案:

nano ~/.bashrc

末尾添加

export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1
           

or

export DISPLAY=`grep -oP "(?<=nameserver ).+" /etc/resolv.conf`:0.0
           

生效

source ~/.bashrc

啟動

startxfce4
           
WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

新開視窗會彈窗按照提示更改設定

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明
https://github.com/microsoft/WSL/issues/4106

用這個模式相當于使用遠端桌面

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

連不上的情況

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

主要是根據bashrc裡面的配置連接配接的,可以指定連接配接:

xfce4-session --display=192.168.1.118:1.0

開不了指令視窗的情況

在 Settings Manager -> Preferred Applications 中重新設定預設終端

或重新安裝 xubuntu-default-settings

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

沒有的話安裝:

apt install xfce4 xfce4-goodies --fix-missing
           

settings

WSL相關修改root密碼重新開機 Windows 10 子系統(WSL) ubuntuhost 說明

沒有的話安裝:

apt install xfce4 xfce4-goodies --fix-missing
           

繼續閱讀