This is regarding "version one"
![]() |
![]() |
(on Wikipedia)
https://github.com/Microsoft/WSL
https://docs.microsoft.com/en-us/windows/wsl/about
A way to run Linux commandline software from a specialized console, similar to how a command prompt runs DOS or PowerShell.
It works well, but it's imperfect.
- aka wsl
-
Sometimes mis-named Bash on Ubuntu on Windows or Bash on Windows
- Not related to Git on Windows.
See also:
- Virtualization
-
XLaunch to run GUI Linux software.
- 2022-07-06 - Switched to Windows Subsystem for Linux 2
- 2021-09-10 - Debian on Windows 10 host, Debian 9.5
- 2021-02-19 - 2 on Windows 10 host, Debian 9.13
- 2019-05-14 - 1 on Windows 10 host, Debian 9.9.0-i386-xfce-CD-1 guest.
- I tried Cygwin a tiny bit.
- I used to use Babun.
-
2018-10-10 - I used to use Git on Windows
- I use Debian (Debian in the Microsoft store)
--
--
- https://docs.microsoft.com/en-us/archive/blogs/wsl/ [ 1 ]
- See also My Windows Subsystem for Linux scripts.
-
2019-07-17 - alt-space doesn't work
- I can't figure out how to get AutoHotkey to do this.
2021-09-10 - Debian ∞
You might need to do this as Administrator in PowerShell:
(A reboot may be required)
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
To learn what is available:
wsl --list --online
To install:
wsl --install --distribution Debian
No reboot is required.
2021-02-19 - 2 ∞
Installation ∞
wsl --set-version Debian 2
But it doesn't work.
# wsl -l -v wsl --list --verbose
NAME STATE VERSION * Debian Stopped 1
Trying
https://docs.microsoft.com/en-ca/windows/wsl/install [ 2 ]
:: As administrator dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Download and run https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
In PowerShell:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux wsl --set-default-version 2
~~ TODO
2019-07-19 ∞
[fails] - installation attempt ∞
This is for Windows insiders. Sigh.
I think this is how it's done, but I don't know how to test.
Run Powershell as admin.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux # (You may need to reboot) Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform # Reboot # Learn what you have installed wsl --list # Change to whatever you have installed wsl --upgrade Debian
Note that Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
might make VirtualBox fail to start, with Call to WHvSetupPartition failed.
2018-10-10 ∞
Installation ∞
0. Preparation
You will be prompted to reboot.
1. Open PowerShell as Administrator
Open cmd
as Administrator and type powershell
.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
2. Install Debian
When prompted, choose to launch it. This will complete its installation.
Shortcuts ∞
By default, you will have a new "Debian GNU/Linux" in you start menu.
Shortcut to your home directory ∞
If you want to create a shortcut, you can make it with the target:
%windir%\System32\bash.exe ~
Or
%windir%\System32\wsl.exe ~
Shortcut to the current directory ∞
You can also make the target like the above, without the trailing ~
, like either of these:
%windir%\System32\bash.exe %windir%\System32\wsl.exe
And then make Start in
%V
Make blue on black legible ∞
As of 2019-01-07 this is unnecessary.
- Use ColorTool (downloads)
- they know this
- Introducing the Windows Console Colortool
-
See also 24-bit Color in the Windows Console!
The easy way:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Console] "ColorTable00"=dword:000c0c0c "ColorTable01"=dword:00da3700 "ColorTable02"=dword:000ea113 "ColorTable03"=dword:00dd963a "ColorTable04"=dword:001f0fc5 "ColorTable05"=dword:00981788 "ColorTable06"=dword:00009cc1 "ColorTable07"=dword:00cccccc "ColorTable08"=dword:00767676 "ColorTable09"=dword:00ff783b "ColorTable10"=dword:000cc616 "ColorTable11"=dword:00d6d661 "ColorTable12"=dword:005648e7 "ColorTable13"=dword:009e00b4 "ColorTable14"=dword:00a5f1f9 "ColorTable15"=dword:00f2f2f2
Add context menu ∞
It's supposed to be there, but isn't..
-
- This has been modified to use Zsh as a shell. It's a bit hackish.
-
Unfortunately, due to the nature of WindowsApps, I cannot provide something that will work unmodified. Change
SOMETHING
to your appropriate code.- I used Process Lasso, then did
--right-click
> Locate > Locate executable on disk ...
- I used Process Lasso, then did
Note that there is no simple way to expand something like %windir%
in a .reg file. The default is a REG-SZ
type, but you have to encode it as hex to make it a REG_EXPAND_SZ
type.
Windows Registry Editor Version 5.00 ; Get 'TheDebianProject.DebianGNULinux_SOMETHING' from ; C:\Program Files\WindowsApps\ [HKEY_CLASSES_ROOT\Directory\Background\shell\Debian] @="Debian &Shell" ; This will likely be particular to the user. "Icon"="C:\\Program Files\\WindowsApps\\TheDebianProject.DebianGNULinux_SOMETHING\\debian.exe" [HKEY_CLASSES_ROOT\Directory\Background\shell\Debian\Command] @="debian.exe run bash.exe -c zsh" [HKEY_CLASSES_ROOT\Directory\shell\Debian] @="Debian &Shell" ; This will likely be particular to the user. "Icon"="C:\\Program Files\\WindowsApps\\TheDebianProject.DebianGNULinux_SOMETHING\\debian.exe" [HKEY_CLASSES_ROOT\Directory\shell\Debian\Command] @="debian.exe run bash.exe -c zsh"
Usage and troubleshooting ∞
Locating the files from Windows ∞
For Debian it will be something like:
C:\Users\$USERNAME\AppData\Local\Packages\TheDebianProject.DebianGNULinux_$CODE\LocalState\rootfs
Replace $USERNAME
and $CODE
as appropriate.
Visit C:\Users\$USERNAME\AppData\Local\Packages\
to figure out your installation code. Why is it done like this? Who knows! Maybe it's for the same reason Firefox does it: To make it (somehow) difficult for attacks to find that directory.
Using the WSL files from within Windows [DO NOT DO THIS!] ∞
Due to the nature of Microsoft's fuckery, you can sort of access things, but DO NOT ADD ANYTHING AND DO NOT MAKE CHANGES or you will corrupt the everloving fuck out of your whole thing.
TODO - One possible solution: https://docs.microsoft.com/en-us/archive/blogs/wsl/wsl-file-system-support [ 4 ]
Running GUI Linux software on Windows Subsystem for Linux ∞
Use XLaunch
Mounting a USB drive ∞
\sudo \mkdir /mnt/d # You may need to try this multiple times. # Be sure to not be in this directory. \sudo \mount -t drvfs d: /mnt/d
Why isn't this possible by default? Who knows!
Mounting a network drive ∞
If it does not already have a drive letter, but does have a UNC path, you'd do:
\sudo \mkdir /mnt/share \sudo \mount -t drvfs '\\server\share' /mnt/share
Issues ∞
-
2020-05-20 -- I can't run a script if it's already in use.
-
2019-02-17 -- For some time I haven't been able to properly run some scripts. They seem to be mangled or chopped up somehow, and the attempt to execute them only sees some of the text in the file.
- I expect that this is some sort of encoding difference. Maybe it's line endings, but
dos2unix
didn't work. I think perhaps it's some sort of international character encoding thing, like UTF-8 versus whatever. - Everything looks fine with less and Nano. Scripts which I create with Nano work as-expected. Maybe I have to re-create all magically-broken files.
- I expect that this is some sort of encoding difference. Maybe it's line endings, but
-
While I figured out how to create a shortcut with a hotkey, I cannot open multiple terminal instances with that hotkey.
- For some time, the development team has been overhauling their terminal, and they are aware of the desire for a tabbed terminal.
-
Permissions are not retained, and chmod is either ignored or has an error.
- This must be fixed within Windows itself. I set all permissions as inheritable for all objects I'm trying to access (and subdirectories).
- Doesn't prompt when you close the terminal.
-
Cannot use a hotkey to paste into a terminal
- Supposedly solved by Windows Insider build 17643
- https://insider.windows.com/en-us/
- You can edit the preferences, and turn insert mode on, and then
right-click
to paste. - Can be solved via AutoHotkey
Footnotes
- was blogs.msdn.microsoft.com/wsl/ - [↩]
- was https://docs.microsoft.com/en-ca/windows/wsl/install-win10 - [↩]
- was https://docs.microsoft.com/en-us/windows/wsl/install-win10 - [↩]
- was logs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/ - [↩]
Mounting a USB drive. Yes, something as simple as that actually required research and documentation.
`alt-space` still doesn't work to open the top-left menu..