I'll grudgingly admit that Windows Subsytem for Linux isn't bad like I thought it would be. That said, there are several things you might want to do to make it more livable.
First, to enable WSL at all (from here), in adminstrator powershell:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Then, it still being Windows, you have to restart.
Windows Store is a garbage zone. Here's the spell for skipping that part (from here). Just download this URL and double click what you get:
https://aka.ms/wsl-ubuntu-1804
Other URLs exist for other distros; you're on your own for that.
The distro will be installed as an "app", which is Windows 10 speak for "dumbed down program that's treated in special ways that break normal workflows". If you have classic Start and Launchy, to make it work with Launchy:
The default package set is actually not bad. But this will update and install what's missing:
sudo apt update sudo apt dist-upgrade sudo apt install lynx links binutils zip unzip gdb build-essential dos2unix
Bigger list:
sudo apt install at bc bzip2 default-jdk dos2unix fdisk ffmpeg build-essential gdb hashdeep valgrind lynx links wget curl ltrace strace manpages-dev mdadm nasm net-tools netcat nmap pv spim zip unzip whois x11-apps
To get to places easily:
ln -s /mnt/c/Users/$USER ~
It turns out there already is one by default, but it only shows if you shift right click. To make it always visible (per here):
HKEY_CLASSES_ROOT\Directory\shell\WSL
, delete the key Extended
I'm used to saying start .
to open an explorer in this directory. Using this recipe, you can add the following to ~/.bashrc to restore this functionality:
alias start="powershell.exe /c start"
By default, there's no keyboard shortcut to scroll the Windows terminal. Per here, a quick duct tape solution is to use the following script in AutoHotKey:
#IfWinActive ahk_class ConsoleWindowClass +PgUp:: Send {WheelUp} Return +PgDn:: Send {WheelDown} Return #IfWinActive
I just upgraded to Ubuntu 22.04 WSL, and found that some IO requests to /mnt/c were getting permission denied. Upon investigating, I found that the old WSL (which worked) had this output for mount:
C:\ on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
And the new one had:
C:\ on /mnt/c type drvfs (rw,noatime,uid=0,gid=0,case=off)
The fix is to set UID for the WSL mounts. This can be done by editing /etc/wsl.conf and adding:
[automount] options = "uid=1000,gid=1000"
By default, WSL just mounts physical drives around at boot. This script mounts all drives Windows knows about to directories under /mnt:
for DRV in `wmic.exe logicaldisk get name | grep : | awk '{print tolower($1)}'` ; do MNT=/mnt/${DRV::1} if mount | grep -q $MNT ; then echo $MNT already mounted else sudo mkdir -p $MNT sudo mount -t drvfs $DRV $MNT fi done