# WSL雜紀 ###### tags: `WSL` ### port衝突問題 port是先搶先贏, 如果本地有服務站用某個port, WSL就無法使用這個port, 因為WSL與host端是內部區域網路 因此從host端連入WSL的特定port的服務 無法使用localhost直接連到 必須要指定IP才可以, ### 列出幾個常用WSL指令 從來源[1][6]中擷取幾個常用指令 指令|功能 ---|--- wsl -l -v | 列出目前已經安裝的 WSL Distro 版本<br>(包含顯示執行狀態與 WSL 版本) wsl -l -q | 列出所有的 WSL Distro 版本<br>(僅顯示 WSL Distro 名稱)(方便做 CLI 整合) wsl --export WLinux D:\WSL\WLinux.tar | 將WLinux匯出為WLinux.tar wsl --import WLinux C:\WSL\WLinux WLinux.tar | 匯入特定 WSL Distro 版本 wsl -d WLinuxDev | 啟動特定 WSL Distro並進入shell wsl -d Ubuntu-20.04 -u root | 啟動特定 WSL Distro並使用特定使用者進入shell wsl -t WLinux | 關閉特定 WSL Distro wsl --shutdown | 關閉所有 WSL Distro <br>(等同於關閉 VM 執行) wsl --unregister WLinux2 | 移除 WSL Distro 版本<br>(注意:所有該 WSL Distro 下所有的檔案,都會被全數刪除,刪除後無法復原喔!) wsl hostname -I | (來源[6]) 取得預設WSL Distro的內部IP wsl -d "distroname" hostname -I | (來源[6]) 取得指定WSL Distro的內部IP wsl --set-default "distroname" | (來源[6]) 設定預設WSL Distro 從內部執行 指令|功能 ---|--- explorer.exe . |從 WSL Distro 內執行以下命令,就可以快速開啟「檔案總管」並且直接進入你在 WSL Distro 內的資料夾,超級方便!<br>(請注意:你一定要輸入 explorer.exe . 才可以,若是輸入 explorer . 是沒有效果的。)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up