Install/uninstall Bash on Windows from command line

My name is Ito and I am an infrastructure engineer.

Do you use Bash on Windows?

I previously wrote about the installation method on this blog.
How to use Bash after Windows 10 Anniversary Update | Beyond Inc.

After it was released, I started messing around with it, wondering what it could do, and
I ended up forgetting what state it was in. I
didn't have any particularly important files, so
I thought I'd just make it again.

I wondered if there was a way to do this quickly from the command line...and I was able to

lxrun command

You can install or uninstall Bash on Windows using the lxrun command from the command prompt (administrator privileges)

To install it, you must first install the Windows Subsystem for Linux from the Control Panel. (
See How to Use Bash with the Windows 10 Anniversary Update | Beyond Inc.)
This is because the lxrun command itself is stored in the Windows Subsystem for Linux.

Let's take a look

λ lxrun /? Performs management operations for LX subsystems Usage: /install - Installs the subsystem Optional arguments: /y - Does not prompt the user for permission /uninstall - Uninstalls the subsystem Optional arguments: /full - Performs a full uninstall /y - Does not prompt the user for permission /setdefaultuser - Configures the subsystem user that bash starts as. If the user does not exist it will be created. Optional arguments: username - Specify a username /y - If a username is specified, do not prompt for password creation /update - Updates the package index for the subsystem

The command is super simple.
Let's try deleting it.

λ lxrun /uninstall /full This will uninstall Ubuntu on Windows. The Ubuntu environment and all modifications, new applications, and user data will be removed. Enter "y" to continue: y Uninstalling... λ bash -- Beta Feature -- This will install Ubuntu on Windows. Ubuntu is a product distributed by Canonical and is licensed under the terms found at: https://aka.ms/uowterms Enter "y" to continue:

It appears to have been successfully uninstalled.
(If it is installed, Bash on Windows will start with the bash command.)

Installation can be done using the current "bash" command or "lxrun /install"

λ lxrun /install -- BETA FEATURE -- This will install Ubuntu on Windows. Ubuntu is a product distributed by Canonical and is licensed under the terms at: https://aka.ms/uowterms Enter "y" to continue: y Downloading from Windows Store... 100% Extracting file system. This may take a few minutes... Create a default UNIX user account. The username does not need to match your Windows username. More information: https://aka.ms/wslusers Enter new UNIX username: unixuser Enter new UNIX password: Re-enter new UNIX password: passwd: password updated successfully Installation completed successfully λ bash unixuser@BYD-PC-15:/mnt/c/Users/itou$

Yeah, it's easy!

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
1,711
X facebook Hatena Bookmark pocket

The person who wrote this article

About the author