How can the bash shell on Window be completely reset?

3

3

I'm new to Unix but interested learn, so started trying to use bash/Ubuntu on Windows. Unfortunately, bash crashed and now bash/Ubuntu seems to be broken as most folders are now missing from the Ubuntu root folder, i.e.:

root@Desktop:~# ls
root@Desktop:~# cd /root
root@Desktop:~# ls
root@Desktop:~# ls -a
.  ..  .bashrc  .profile

I don't have a %localappdata%\lxss folder (I'm pretty certain this is where the Linux root was originally). I appear to have a %localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc folder, which is apparently the new location for the Linux root, but it is not complete (i.e. doesn't contain a ...\LocalState\rootfs folder).

After searching for solutions on here and elsewhere, I've tried:

  • Completely uninstalling Ubuntu\bash from Windows with lxrun.exe /uninstall full.
  • As above, in conjunction with disabling and re-enabling the Windows Subsystem for Linux (beta) feature too.
  • Running: apt-get remove upstart, apt-get remove udev, apt-get autoremove in bash.

Unfortunately none of the above have solved the problem. Can anybody suggest a way to perform a complete 'factory reset'?

Robert

Posted 2018-01-03T19:36:55.090

Reputation: 33

bash is a program. It can run, for example, in a cmd.exe window (if you have it built as a Windows executable). Ubuntu is a Linux distribution - which is built around the Linux kernel, that runs on the "bare metal" - not as a Windows application. So it's not quite clear what you mean when you write "base/Ubuntu" is broken. – einpoklum – 2018-01-03T19:45:20.817

1Which version are you trying to run: the beta release from the developers' options, or the official release from the Windows store, available with the 1709 upgrade? If you have both installed, then I can imagine that the installation would get confused. Make sure both are uninstalled, then re-install the version you want to use. Note that it is not unusual to have only a few files in the root home directory: ls / will show whether you have a reasonable directory structure. – AFH – 2018-01-03T19:46:21.117

You are trying solutions for the legacy (Beta) WSL. You need to use the commands for the current version of WSL which only work on 1709. In order to reset WSL on Windows 10 Version 1709 you need to remove Ubuntu from the Windows Store then simply install it again from the Windows Store. – Ramhound – 2018-01-03T21:25:35.800

If you are not running the current build of Windows 10 Version 1709, update your question with a screenshot of the output of winver, be sure to remove any license or PPI. – Ramhound – 2018-01-03T21:38:53.803

Hi @Ramhound. I think you're correct, thank you -- the problem appears to have stemmed from my confusion between the legacy (Beta) WSL that I had been running and WSL on Windows 10 Version 1709, which I am running. – Robert – 2018-01-03T22:50:20.693

Answers

0

After searching for solutions on here and elsewhere, I've tried:

  • Completely uninstalling Ubuntu\bash from Windows with lxrun.exe /uninstall full.
  • As above, in conjunction with disabling and re-enabling the Windows Subsystem for Linux (beta) feature too.
  • Running: apt-get remove upstart, apt-get remove udev, apt-get autoremove in bash.

lxrun.exe isn't supposed to work on the current version of WSL. I find it difficult to believe you have installed the Windows Subsystem for Linux (Beta) since the correct feature would be listed as Windows Subsystem for Linux on Windows 10 Version 1709. Your third solution wouldn't reset the any WSL environment.

lxrun and bash.exe and associated tools are deprecated in the Fall Creators Update.

The only reason I know you are running 1709 is due to the existence of the UbuntuonWindows_79rhkp1fndgsc folder.

I appear to have a %localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc folder, which is apparently the new location for the Linux root, but it is not complete (i.e. doesn't contain a ...\LocalState\rootfs folder).

It isn't supposed to contain that folder.

I don't have a %localappdata%\lxss folder (I'm pretty certain this is where the Linux root was original).

This is the location of the legacy version of WSL. It is no longer located there, and the legacy method used to reset the environment does not work for the current version of WSL on Windows 10 Version 1709+

I specifically said that in my answer.

The following answer only applies to WSL on Windows 10 1703 and 1607. WSL on Windows 10 1709+ can be installed from within the Windows Store UWP application.

As for your actual question...

Unfortunately none of the above have solved the problem. Can anybody suggest a way to person a complete 'factory reset'?

Just run the command:

wslconfig /unregister Ubuntu

Additionally, wslconfig /unregister, unregisters the distribution from WSL so it can be reinstalled or cleaned up.

Caution: Once unregistered, all data, settings, and software associated with that distribution will be permanently lost. Reinstalling from the store will install a clean copy of the distribution.

Once you run that command you will have to reinstall Ubuntu through the Windows Store.

While Linux distributions can be installed through the Windows store, they can't be uninstalled through the store. WSL Config allows distributions to be unregistered/uninstalled.

Manage multiple Linux Distributions in WSL

Command Reference

Ramhound

Posted 2018-01-03T19:36:55.090

Reputation: 28 517