Install/uninstall Bash on Windows from command line
My name is Ito and I am an infrastructure engineer.
Are you using Bash on Windows?
I previously wrote about how to install it on this blog.
How to use Bash after Windows 10 Anniversary Update | Beyond Inc.
After it was released, I was playing around with it wondering what it could do, and
help but wonder what kind of situation it was in.
I didn't have a particularly important file in there, so
I thought I'd create it again.
Is it possible to do it from the command line? I was able to do it.
lxrun command
You can install or uninstall Bash on Windows using the lxrun command from a command prompt (administrator privileges).
*To install, you must first install Windows Subsystem for Linux from the control panel.
How to use Bash after Windows 10 Anniversary Update | Beyond Co., Ltd.
This is because the lxrun command itself is stored in this Windows Subsystem for Linux.
Let's take a look.
λ lxrun /? Performs management operations on the LX subsystem Usage: /install - Installs the subsystem Optional arguments: /y - Does not prompt user for permission /uninstall - Uninstalls the subsystem Optional arguments: /full - performs a complete uninstall /y - does not ask for user permission /setdefaultuser - configures the subsystem user to start bash with. If the user does not exist, it will be created. Optional arguments: username - Specifies the username /y - If a username is specified, do not prompt for a password /update - Update the subsystem's package index
The command is super simple.
I'll try deleting it then.
λ lxrun /uninstall /full This will uninstall Ubuntu on Windows. Your Ubuntu environment and all changes, new applications, and user data will be removed. Enter "y" to continue: y Uninstalling... λ bash -- Beta feature -- This installs Ubuntu on Windows. Ubuntu is a product distributed by Canonical and licensed under the terms found at: https://aka.ms/uowterms Please enter "y" to continue:
It seems that it was successfully uninstalled.
(If it is installed, Bash on Windows will start with the bash command)
Installation can be done with the current "bash" command, or with "lxrun /install".
λ lxrun /install -- Beta feature -- This installs Ubuntu on Windows. Ubuntu is a product distributed by Canonical and licensed under the terms found at: https://aka.ms/uowterms Enter "y" to continue: y Downloading from Windows Store... Extracting 100% file system. This process will take a few minutes... Create a default UNIX user account. The username does not have to match your Windows username. More information: https://aka.ms/wslusers Please enter a new UNIX username: unixuser Please enter a new UNIX password: Re-enter the new UNIX password: passwd: password updated successfully Installation completed successfully λ bash unixuser@BYD-PC-15:/mnt/c/Users/itou$
Yes, it's easy!