Make Windows normal again

Make Windows normal again

An Overview of Developer Tools for Windows - Welldone Software - Medium

WSL Related

Linux’izing your Windows PC into a dev machine – Part 2 |

Composer on WSL


The mysql user folder is not set correctly by default and the server will complain about it when started (No directory, logging in with HOME=/). To fix, change the mysql user’s home directory to /var/lib/mysql:

sudo usermod -d /var/lib/mysql mysql

I had to add protocol=TCP in /etc/mysql/my.cnf

In my app living in WSL, changing the host from localhost to in also helped.

# /etc/mysql/mysqld.conf.d/mysqld.conf

sudo add-apt-repository ppa:mysql-ubuntu/mariadb-10.1
sudo apt-get update
sudo apt-get install mariadb-server

grep socket -R /etc/mysql/

## /etc/mysql/mysql.conf.d/mysqld.cnf

Go to the file /etc/mysql/debian.cnf which has as the format:

host     = localhost
user     = debian-sys-maint
password = XXXXXXXX
socket   = /var/run/mysqld/mysqld.sock 
Take from there the password, that is randomly generated when installing MySQL (e.g. it differs between servers);

mysql -udebian-sys-maint -p02cShQo3PUHOFfzY

mysql -udebian-sys-maint -p02cShQo3PUHOFfzY --protocol TCP -h

[WSL 2] NIC Bridge mode 🖧 (Has Workaround🔨) · Issue #4150 · microsoft/WSL · GitHub

Find the IP address of your WLS2 Ubuntu host (use ifconfig) and connect to that IP using your Web browser.

sudo usermod -aG docker $USER

You will need to log out for this change to take effect.


Install WSL 2 on Windows 10

You will need to start PowerShell as an Administrator, you might need a restart of your computer afterwards.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Download and install WSL Linux distribution based on Ubuntu 18.04 from the Microsoft Store. After that, type:

# if you don't have WSL 2 this command will not recognize "-v" switch
wsl -l -v

When you get WSL 2, you can do the following:

# to convert existing distribution (in my case: Ubuntu-18.04) to WSL 2
wsl --set-version Ubuntu-18.04 2

# to set WSL 2 as default for future distros
wsl --set-default-version 2

I also suggest to install Windows Terminal (Preview) from Microsoft Store, and Docker Desktop WSL 2 Tech Preview. Don’t forget docker context use wsl.

Best explanation so far: WSL2, zsh, and docker. Linux through Windows Docker Desktop version for WSL2 and was very slow compared from installing Docker by command line inside WSL2.

Nice resource for WSL2 Tricks: shayne/wsl2-hacks. For example, to access IP of WSL2: hostname -I | awk '{print $1}' but localhost also should work. Also sudo sysctl -w fs.inotify.max_user_watches=524288 is needed for Visual Studio Code.

Finally, test with this:

docker run --rm -p 80:80 tutum/hello-world (or nginxdemos/hello)

or even smaller:

docker run --rm -p 80:8000 crccheck/hello-world

localhost:80 should work from host.

Exoscale CLI tool on native Windows

Download from releases and extract exo.exe from zip into c:\bin\exoscale\

Open the command-line shell (cmd.exe) and type the following commands

mkdir \bin\exoscale
setx path "%path%;c:\bin\exoscale;"

Invoking setx can lead to error involving size limit and thus truncating your environment variable. I suggest using a special tool for manipulating Windows PATH variables, like pathed or RapidEE.

Install pathed:

powershell.exe -Command "Invoke-WebRequest -OutFile ./gtools-current.exe"
start /wait gtools-current.exe /S /D=c:\bin\gtools && echo Install finished
del gtools-current.exe
\bin\gtools\pathed /MACHINE /APPEND C:\bin\gtools

Install wget if needed in future, and add that dir to the path:

mkdir \bin\tools
\bin\gtools\pathed /MACHINE /APPEND C:\bin\tools
powershell.exe -Command "Invoke-WebRequest -OutFile /bin/tools/wget.exe"
I had a problem wiping my environment variables, so here they are:

C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\PROGRAMDATA\ORACLE\JAVA\JAVAPATH;C:\PROGRAM FILES (X86)\COMMON FILES\INTEL\SHARED FILES\CPP\BIN\INTEL64;C:\PROGRAM FILES\DELL\DW WLAN CARD;C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\PROGRAM FILES\IDM COMPUTER SOLUTIONS\ULTRAFTP;C:\PROGRAM FILES (X86)\MICROSOFT EMULATOR MANAGER\1.0\;C:\WINDOWS\SYSTEM32\OPENSSH\;C:\PROGRAM FILES\INTEL\WIFI\BIN\;C:\PROGRAM FILES\COMMON FILES\INTEL\WIRELESSCOMMON\;C:\PROGRAM FILES\GIT\CMD;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\AOMEI Backupper;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\Program Files (x86)\ZeroTier\One\;c:\bin\php7;C:\ProgramData\ComposerSetup\bin;c:\bin\exoscale 

%HomeDrive%%HomePath%\cvladan\.babun;%LocalAppData%\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;%LocalAppData%\atom\bin;%LocalAppData%\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\Nmap;%LocalAppData%\Microsoft\WindowsApps;%LocalAppData%\Programs\Microsoft VS Code Insiders\bin;%AppData%\Composer\vendor\bin

(ignore) Make systemd permanent on WSL2

This is needed for snaps to work

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

cat << EOF | sudo tee /etc/profile.d/
SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd$' | grep -v unshare | awk '{print $2}')
if [ -z "$SYSTEMD_PID" ] || [ "$SYSTEMD_PID" != "1" ]; then
    exec sudo /usr/sbin/enter-systemd-namespace
if [ -n "$PRE_NAMESPACE_PATH" ]; then

cat << EOF | sudo tee /usr/sbin/enter-systemd-namespace

if [ "$UID" != 0 ]; then
    echo "You need to run $0 through sudo"
    exit 1

SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd$' | grep -v unshare | awk '{print $2}')
if [ -z "$SYSTEMD_PID" ]; then
    /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd
    while [ -z "$SYSTEMD_PID" ]; do
        SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd$' | grep -v unshare | awk '{print $2}')

if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
    exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a env \
        DISPLAY="$DISPLAY" \
        WSLENV="$WSLENV" \
        WSLPATH="$WSLPATH" \
        /bin/login -p -f "$LOGNAME"

sudo chmod +x /usr/sbin/enter-systemd-namespace

cat << EOF | sudo tee /etc/sudoers.d/wsl2-systemd
Defaults        env_keep += WSLENV
Defaults        env_keep += WSL_INTEROP
Defaults        env_keep += WSL_DISTRO_NAME
Defaults        env_keep += LOGNAME
Defaults        env_keep += PRE_NAMESPACE_PATH
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/enter-systemd-namespace

sudo chmod 0440 /etc/sudoers.d/wsl2-systemd

Now every time you start the terminal/bash it will automatically put you inside a pid namespace with snapd running.

Multipass is WSL2 alternative

Multipass - Orchestrates virtual Ubuntu instances

That’s Ubuntu take on WSL2. Creating an instance is much slower, but much more things work (snaps without hacks). Is also supports cloud-init (as Hetzner Cloud and Exoscale also do). In essence, it is what Vagrant used to be.

multipass launch --name mpass
# or even without name

# enter the instance shell
multipass shell mpass

Working with Multipass instances

To be honest, Vagrant does do that. For sure, just like in theory KVM or Vmware can be used for that too. You can also set up a build farm and a Jenkins server to try to run “hello world”. The advantage of multipass is that to use it, all you have to do is:

snap install multipass

Snaps won’t work on WSL2

snaps don’t work on WSL2 as you need them for every command installed in that way!

The easiest way is to use snap (it is cross-distribution packager):

Using snapd in WSL2 - WSL2 - Ubuntu Community Hub Snapd on WSL2 (Insiders only for now) - snapd - arkane-systems/genie: A quick way into a systemd “bottle” for WSL

sudo apt install -y daemonize

# this must be done on reboot
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd 

# this must be done on every login to WSL
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME 

snap version
sudo snap install kubectl --classic

Compiling kernel on WSL2 is easy: k3s on WSL2

How to register JetBrains PhpStorm

  1. Add the line to hosts file
  2. Enter activation key (mine worked from
  3. We can host our own jetbrains-license-server

Use PhpStorm for WordPress Development

date 01. Jan 0001 | modified 28. May 2021
filename: Windows » Dev Environment » Dump