2022年4月27日

[Windows] WSL 安裝 Ubuntu 系統 (WSL 1)

安裝 Ubuntu 系統

 

  1. 開啟 Microsoft Store,搜尋 Ubuntu,找到想要安裝的 Ubuntu 版本,點選「取得」。

 

  1. 安裝完第一次開啟時會出現下列錯誤:

 

Installing, this may take a few minutes...

WslRegisterDistribution failed with error: 0x8007019e

The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again.

See https://aka.ms/wslinstall for details.

Press any key to continue...

 

必須要啟用 WSL (Windows Subsystem for Linux),才能運行 Ubuntu 子系統。

 

  1. 以系統管理員身分開啟 PowerShell 並執行:

 

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

 

  1. 執行完之後重啟電腦,接著重新運行 Ubuntu 系統即可。第一次運行時,會要求設定帳號密碼。

 

 

存取 C: 磁碟機

 

  • 本機電腦上的硬碟會自動掛載到 Ubuntu 系統的 /mnt 路徑下,掛載點為 /mnt/<磁碟機號>/,因此可以輕鬆存取 Windows 檔案系統。

 

  • 欲瀏覽 C: 磁碟機的檔案,可以使用 cd /mnt/c 來存取 c:\。

 

 

使用提示

 

  • 從 Windows 命令提示字元或 PowerShell,可以直接執行 wsl,在目前的命令列開啟預設的 Linux 發行版本。

 

  • 若要設定與 wsl 命令搭配使用的預設 Linux 發行版本,可以執行:wsl -s <DistributionName> 或 wsl --setdefault <DistributionName>。

 

  • 若要查看線上可用的 Linux 發行版本清單,可以執行:wsl --list --online 或 wsl -l -o。

 

  • 若要運行指定的 Linux 發行版本,可以執行:wsl -d <Distribution Name>。

 

  • 若要以指令的方式安裝 Linux 發行版本,可以執行:wsl --install -d <Distribution Name>。

 

 

參考資料

 

  • Win10自带ubuntu的安装和使用

https://www.dyxmq.cn/other/windows/win10-ubuntu.html

 

  • 適用於 Linux 的 Windows 子系統常見問題集

https://docs.microsoft.com/zh-tw/windows/wsl/faq

 

  • 在 Windows 子系統 Linux 版 上使用 Git 開始

https://docs.microsoft.com/zh-tw/windows/wsl/tutorials/wsl-git



沒有留言:

發佈留言

和我聯絡

姓名

電子郵件 *

訊息 *