简体   繁体   English

是否可以在没有 Microsoft Store 的情况下在 Windows 10 WSL 中安装 Ubuntu?

[英]Is it possible install Ubuntu in Windows 10 WSL without Microsoft Store?

On my work are not allowed to install apps from the Microsoft Store.我的工作不允许从 Microsoft Store 安装应用程序。 Yes, this is a bank, that not supported Windows 10 (it's hell).是的,这是一家不支持 Windows 10 的银行(简直是地狱)。

Is it possible to install Ubuntu in WSL without downloading it from the app store?是否可以在 WSL 中安装 Ubuntu 而无需从应用商店下载?

Or is it possible to download Ubuntu app without Microsoft Store and then install it?或者是否可以在没有 Microsoft Store 的情况下下载 Ubuntu 应用程序然后安装它?

Yes, it is possible to download the app without the Store.是的,可以在没有商店的情况下下载该应用程序。 Some available distributions are listed in the Manual Installation section of the MS guide ( https://docs.microsoft.com/en-us/windows/wsl/install-manual ) MS 指南的“手动安装”部分列出了一些可用的发行版 ( https://docs.microsoft.com/en-us/windows/wsl/install-manual )

The actual manual installation instructions are hidden in the Server Install section of the manual ( https://docs.microsoft.com/en-us/windows/wsl/install-on-server ), but my understanding is that you can just run the .appx file you downloaded and it should work anyway.实际的手动安装说明隐藏在手册的服务器安装部分( https://docs.microsoft.com/en-us/windows/wsl/install-on-server ),但我的理解是您可以运行您下载的 .appx 文件,它应该可以正常工作。

Whether it's wise to install WSL/Ubuntu on a work computer that you don't control is another question, but one which only you can answer.在您无法控制的工作计算机上安装 WSL/Ubuntu 是否明智是另一个问题,但只有您可以回答。

I had the same problem, could do it like this (from PowerShell):我有同样的问题,可以这样做(来自 PowerShell):

# go into some folder into which you want the file to be downloaded
cd <somefolder>

# download Ubuntu 20.04
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

# install downloaded *.appx file
Add-AppxPackage .\Ubuntu.appx

Afterwards I did Windows + S and typed "Ubuntu" to show the installed app, then executed it to finish setup (new user name + password must be given).之后我做了Windows + S并输入“Ubuntu”以显示已安装的应用程序,然后执行它以完成设置(必须提供新用户名 + 密码)。

I checked the success doing: wsl --list --verbose and received this:我检查了成功: wsl --list --verbose并收到了这个:

  NAME                   STATE           VERSION
  Ubuntu-20.04           Running         1

So finally, I needed to convert my Ubuntu to WSL2 like this:所以最后,我需要像这样将我的 Ubuntu 转换为 WSL2:

wsl --set-version Ubuntu-20.04 2

Voila!瞧!

Yes, It is possible to install Ubuntu without opening the store.是的,可以在不打开商店的情况下安装 Ubuntu。

  1. Open settings in windows and enable developer mode.在 Windows 中打开设置并启用开发人员模式。

  2. Once the developer mode is enabled, Go to Windows search and Type Bash.启用开发人员模式后,转到 Windows 搜索并键入 Bash。

  3. It will open Bash command prompt.它将打开 Bash 命令提示符。 Allow it to download Ubuntu automatically.允许它自动下载 Ubuntu。

Cheers!!!干杯!!!

I created a powershell script to install wsl2 with optional X-Windows and Pulse Audio support.我创建了一个 powershell 脚本来安装带有可选的 X-Windows 和 Pulse Audio 支持的 wsl2。 I also captured my experience with installing wsl without Store access in the Readme.md.我还在 Readme.md 中记录了在没有 Store 访问权限的情况下安装 wsl 的经验。

For the detail see here: https://github.com/andras-varro/wsl2i有关详细信息,请参见此处: https : //github.com/andras-varro/wsl2i

I believe these are the most important points:我认为这些是最重要的几点:

  1. Check if your installation supports WSL2: Windows logo key + R, type winver [enter].检查您的安装是否支持 WSL2:Windows 徽标键 + R,键入 winver [enter]。 You should have Version 1903 or higher, with Build 18362 or higher您应该拥有版本 1903 或更高版本,以及 Build 18362 或更高版本

  2. Enable WSL2启用 WSL2

    1. Open an admin prompt (Press shift+ctrl and click on PowerShell/cmd)打开管理员提示(按 shift+ctrl 并单击 PowerShell/cmd)
    2. dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    3. Reboot your computer重启你的电脑
    4. Download and install the WSL2 kernel from: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi从以下位置下载并安装 WSL2 内核: https ://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
    5. Open a PowerShell or cmd and execute: wsl --set-default-version 2打开 PowerShell 或 cmd 并执行:wsl --set-default-version 2
  3. Install a Linux distro安装 Linux 发行版

    1. Please only download an available distro from here: https://docs.microsoft.com/en-us/windows/wsl/install-manual Explanation: if you install through appx installer without Windows Store enabled, you might run into a 'File not found' or 0x80070002 error.仅从此处下载可用的发行版: https ://docs.microsoft.com/en-us/windows/wsl/install-manual 说明:如果您通过 appx 安装程序安装而未启用 Windows 应用商店,则可能会遇到“文件未找到'或 0x80070002 错误。
    2. Create a location on your system drive (see: https://docs.microsoft.com/en-us/windows/wsl/install-win10#troubleshooting-installation , but it works for me on D: drive) where you want your distro to run from (like c:\\work\\wsl)在您的系统驱动器上创建一个位置(请参阅: https : //docs.microsoft.com/en-us/windows/wsl/install-win10#troubleshooting-installation ,但它在 D: 驱动器上对我有用)您想要的位置要运行的发行版(如 c:\\work\\wsl)
    3. Extract the downloaded distro appx file using your favorite zip tool (7Zip or WinZip or ..) into the selected location (Right click on the appx and extract to the created folder (like c:\\work\\wsl))使用您最喜欢的 zip 工具(7Zip 或 WinZip 或 ..)将下载的发行版 appx 文件解压缩到所选位置(右键单击 appx 并解压缩到创建的文件夹(如 c:\\work\\wsl))
    4. Set access rights for your Linux installer folder so that everybody has all the rights Open a cmd or PowerShell and execute: icacls [your folder] /t /grant Everyone:(OI)(CI)F Example: icacls c:\\work\\wsl /t /grant Everyone:(OI)(CI)F为您的 Linux 安装程序文件夹设置访问权限,以便每个人都拥有所有权限 打开 cmd 或 PowerShell 并执行:icacls [您的文件夹] /t /grant Everyone:(OI)(CI)F 示例:icacls c:\\work\\wsl /t /grant 每个人:(OI)(CI)F
    5. Start the setup as Administrator.以管理员身份开始设置。 Example with Ubuntu: right click on ubuntu2004.exe and select Run as adminsitrator Ubuntu 示例:右键单击 ubuntu2004.exe 并选择以管理员身份运行
    6. Follow the on screen instructions按照屏幕上的说明进行操作
  4. Test your WSL2测试你的 WSL2

    1. After the setup finished and you have the Linux command prompt try to start bash from Windows' Run (Win+R)设置完成后,你有 Linux 命令提示符尝试从 Windows 的运行 (Win+R) 启动 bash
    2. Exit from the started bash and from the bash you got after the installation从启动的 bash 和安装后获得的 bash 退出
    3. Start bash from Windows' Run (Win+R) (again)从 Windows 的 Run (Win+R) 启动 bash(再次)

You can use winget (Windows Package Manager):您可以使用winget (Windows 包管理器):

winget install -e --id Canonical.Ubuntu

To get another version than the "latest", search for them via:要获得“最新”之外的另一个版本,请通过以下方式搜索它们:

winget search -s winget Ubuntu

If you omit the -s winget option, the versions from other sources like the Microsoft store will be displayed too.如果省略-s winget选项,来自其他来源(如 Microsoft 商店)的版本也会显示。

Iin an administrator PowerShell or Windows Command Prompt and then restarting your machine:在管理员 PowerShell 或 Windows 命令提示符下,然后重新启动您的机器:

wsl --install --distribution Ubuntu

You can get distributions list by:您可以通过以下方式获取分发列表:

wsl --list --online

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM