如何卸载(或重新安装)Windows 10的Ubuntu Bash Shell

Windows 10’s new Ubuntu-based Bash shell doesn’t function like a normal program. To uninstall it or reset its state to get a fresh Linux environment, you’ll need to use a few special commands.

Windows 10的新的基于Ubuntu的Bash shell不能像普通程序那样运行。 要卸载它或重置其状态以获得全新Linux环境,您将需要使用一些特殊命令。

Update: As of the Fall Creators Update, you can now uninstall Ubuntu or any other Linux distribution like a normal application. For example, to uninstall Ubuntu, just right-click the Ubuntu shortcut in your Start menu and click “Uninstall”. To reinstall a Linux distribution, download it from the Store once again. When you reinstall, you’ll get a fresh copy of the Linux environment.

更新 :从Fall Creators Update开始 ,您现在可以卸载Ubuntu或任何其他Linux发行版,例如普通应用程序。 例如,要卸载Ubuntu,只需在开始菜单中右键单击Ubuntu快捷方式,然后单击“卸载”。 要重新安装Linux发行版,请再次从商店下载它。 重新安装后,您将获得Linux环境的全新副本。

You can also run the ubuntu clean command in a Command Prompt or PowerShell window to delete your Ubuntu Linux file system. The next time you launch Ubuntu, it will set up a new file system without you having to redownload the software.

您也可以在命令提示符或PowerShell窗口中运行ubuntu clean命令来删除Ubuntu Linux文件系统。 下次启动Ubuntu时,它将建立一个新的文件系统,而无需重新下载该软件。

All of the below commands can either be run in a Command Prompt window or a PowerShell window.

以下所有命令均可在命令提示符窗口或PowerShell窗口中运行。

Right-click the Start button or press Windows+X on your keyboard and select “Command Prompt” to open a Command Prompt window. If you’d like to use PowerShell instead, you can launch PowerShell from the Start menu.

右键单击开始按钮或按键盘上的Windows + X,然后选择“命令提示符”以打开命令提示符窗口。 如果您想改用PowerShell,则可以从“开始”菜单启动PowerShell。

如何卸载Ubuntu环境并保留主文件夹 (How to Uninstall the Ubuntu Environment and Keep Your Home Folder)

Update: As of the May 2019 Update, use the wsl command instead of the lxrun command. For example, to uninstall a Linux distribution, that’s:

更新 :从2019年5月更新开始 ,使用wsl命令而不是lxrun命令。 例如,要卸载Linux发行版,那就是:

wsl --unregister DistributionName

For example, to uninstall Ubuntu, you’d run:

例如,要卸载Ubuntu,请运行:

wsl --unregister Ubuntu

You can run wsl --list  to see a list of installed Linux distributions and their names.

您可以运行wsl --list来查看已安装Linux发行版及其名称的列表。

On older versions of Windows 10, to remove the downloaded Bash environment, open a Command Prompt window and run the following command. This will uninstall and delete the Ubuntu user environment from your system, including any Linux applications you downloaded and installed with apt-get or by compiling them from source.

在Windows 10的旧版本上,要删除下载的Bash环境,请打开命令提示符窗口并运行以下命令。 这将从您的系统中卸载和删除Ubuntu用户环境,包括您使用apt-get下载或安装的任何Linux应用程序,或者从源代码进行编译。

lxrun /uninstall

Windows will ask you to confirm your choice. To automatically accept the confirmation–ideal if you want to use this command in a script, for example–run the lxrun /uninstall /y command instead.

Windows会要求您确认选择。 要自动接受确认(例如,如果要在脚本中使用此命令,则是理想选择),而是运行lxrun /uninstall /y命令。

This command won’t delete your home folder and the files in it. If you’d like to completely wipe the Linux system, see the next section.

此命令不会删除您的主文件夹及其中的文件。 如果您想彻底擦除Linux系统,请参阅下一节。

如何卸载Ubuntu环境并删除主文件夹 (How to Uninstall the Ubuntu Environment and Delete Your Home Folder)

The above command won’t delete your Ubuntu user account’s home folder. The home folder contains user preferences and files. If you install a new Ubuntu user space image, the files in your home folder will be preserved and carried over.

上面的命令不会删除您的Ubuntu用户帐户的主文件夹。 主文件夹包含用户首选项和文件。 如果您安装新的Ubuntu用户空间映像,则主文件夹中的文件将被保留并转移。

If you want to prevent this from happening, you’ll need to remove the downloaded Bash environment and completely wipe your home folder. To do so, run the following command:

如果要防止这种情况发生,则需要删除下载的Bash环境并完全擦除主文件夹。 为此,请运行以下命令:

lxrun /uninstall /full

You’ll be asked to confirm your choice. To automatically accept the confirmation, run the lxrun /uninstall /y /full command instead.

系统会要求您确认选择。 要自动接受确认,请lxrun /uninstall /y /full运行lxrun /uninstall /y /full命令。

如何重新安装Ubuntu环境 (How to Reinstall the Ubuntu Environment)

To reinstall the Bash environment, you can just run the bash command again, as you did when installing Bash the first time. If a Ubuntu user space image isn’t installed, it will automatically download and install it.

要重新安装Bash环境,您可以再次运行bash命令,就像第一次安装Bash一样。 如果未安装Ubuntu用户空间映像,它将自动下载并安装。

You can also run the following command yourself. This is the same command that bash.exe automatically runs if you launch it without a Ubuntu user space image installed.

您也可以自己运行以下命令。 如果在未安装Ubuntu用户空间映像的情况下启动bash.exe,则该命令与bash.exe自动运行的命令相同。

lxrun /install

Whether you run bash or lxrun /install , the command will ask you to confirm your choice and enter a username and password for the user account in the Bash environment.

无论是运行bash还是lxrun /install ,该命令都将要求您确认选择,并在Bash环境中输入用户帐户的用户名和密码。

To skip this process, you can run the following command instead. This command will automatically agree to the prompts, setting the “root” account as the default user account without a password. This is helpful if you want to automate the process of installing Bash in a script.

要跳过此过程,可以改为运行以下命令。 该命令将自动同意提示,将“ root”帐户设置为没有密码的默认用户帐户。 如果要自动在脚本中安装Bash的过程,这将很有帮助。

lxrun /install /y

如何完全删除Windows 10的Bash工具 (How to Remove Windows 10’s Bash Tools Completely)

If you’d like to remove the bash.exe tool and the Windows Subsystem for Linux from your computer completely, you’ll need to revisit the “Turn Windows Features On or Off” dialog in the Control Panel.

如果您想从计算机上完全删除bash.exe工具和Windows子系统Windows,则需要重新访问“控制面板”中的“打开或关闭Windows功能”对话框。

To find it, open the Control Panel and head to Programs > Turn Windows Features On or Off.

要找到它,请打开控制面板,然后转到程序>打开或关闭Windows功能。

Uncheck the “Windows Subsystem for Linux” option here and click OK. Windows will uninstall the Windows Subsystem for Linux, bash.exe, and lxrun.exe commands. You can always revisit the Windows Features dialog to reinstall them in the future.

在此处取消选中“ Windows Linux子系统”选项,然后单击“确定”。 Windows将卸载适用于Linux的Windows子系统,bash.exe和lxrun.exe命令。 您始终可以重新访问Windows功能对话框,以在将来重新安装它们。

翻译自: https://www.howtogeek.com/261188/how-to-uninstall-or-reinstall-windows-10s-ubuntu-bash-shell/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值