This is more like a notebook entry, rather than full tutorial.
References:
- https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
- https://www.reddit.com/r/bashonubuntuonwindows/wiki/index
In this post I will describe how to install WSL on Windows 10, configure X11 to run any Linux application in GUI mode, and fix missing sound problem.
Base setup
After this step it’s possible to enter Linux environment, but it has few pitfalls.
- Enable developer mode in settings, or use command line alternative (run as Administrator)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
- Enable Windows Subsystem for Linux
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart Windows
- Run
cmd
and:- Either execute
bash
, then follow an installation process - Or,
lxrun /install /y
to install windows with root user and without password (a user can be added later on)
- Either execute
Enhancement
Fix language
ℹ️ Linux inherits original Windows language, so in case on non-English host system, when you feel odd to use non-English️ Linux, you must change it by a bash command:
echo LANG="en_US.utf8" >> ~/.bashrc
Fix sudo
ℹ️ Linux installation inherits Windows host name, but it is not configured fully, sudo
needs to have updated /etc/hosts
file with a right host name
sudo sh -c "echo '127.0.0.1 `hostname`' >> /etc/hosts"
Fix D-BUS
sudo sed -i 's$<listen>.*</listen>$<listen>tcp:host=localhost,port=0</listen>$' /etc/dbus-1/session.conf sudo sed -i 's$<auth>EXTERNAL</auth>$<auth>ANONYMOUS</auth>$' /etc/dbus-1/session.conf sudo sed -i 's$</busconfig>$<allow_anonymous/></busconfig>$' /etc/dbus-1/session.conf
X11 Server
Default export
echo "export DISPLAY=:0.0" >> ~/.bashrc
Windows server
I use xming and it works fine.
Audio support
Solution bases on issue.
Add and install pulse audio
sudo add-apt-repository ppa:aseering/wsl-pulseaudio sudo apt-get update sudo apt-get install libpulse0 -y echo export PULSE_SERVER=tcp:localhost >> ~/.bashrc
Install pulse audio on Windows
ℹ️ it requires unzip
to be installed on Linux.
GIST: install_pulseaudio.bat
The script does:
- download pulse audio from: http://bosmans.ch/pulseaudio/pulseaudio-1.1.zip
- unpack it into:
"%AppData%\PulseAudio
- Creates a start script in
%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\start_pulseaudio.vbe
- With content:
ws.run "%AppData%\PulseAudio\bin\pulseaudio.exe --exit-idle-time=-1",0
- Modifies default settings for pulse audio
@ECHO OFF SET "LINUXTMP=$(echo '%TMP:\=\\%' | sed -e 's|\\|/|g' -e 's|^\([A-Za-z]\)\:/\(.*\)|/mnt/\L\1\E/\2|')" echo LINUXTMP = "%LINUXTMP%" ECHO --- PulseAudio... C:\Windows\System32\bash.exe -xc "wget -cO '%LINUXTMP%/pulseaudio.zip' 'http://bosmans.ch/pulseaudio/pulseaudio-1.1.zip'" ECHO --- Extracting PulseAudio md "%TMP%\pulseaudio" C:\Windows\System32\bash.exe -xc "unzip -o '%LINUXTMP%/pulseaudio.zip' -d '%LINUXTMP%/pulseaudio'" ECHO --- Installing PulseAudio xcopy /e "%TMP%\pulseaudio" "%AppData%\PulseAudio\" ECHO --- Setting PulseAudio to run at startup echo set ws=wscript.createobject("wscript.shell") > "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\start_pulseaudio.vbe" echo ws.run "%AppData%\PulseAudio\bin\pulseaudio.exe --exit-idle-time=-1",0 >> "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\start_pulseaudio.vbe" REM Recomended/required settings echo load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1 >> "%AppData%\PulseAudio\etc\pulse\default.pa" "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\start_pulseaudio.vbe" ECHO When prompted, DO NOT allow 'pulseaudio' access to any of your networks. It doesn't need access. ECHO All Done PAUSE
[…] This is an update for https://trzeci.eu/configure-graphic-and-sound-on-wsl/ […]
Thank you very much!
However, I had to edit the start_pulseaudio.vbe script, so it contained the following
ws=wscript.createobject(“wscript.shell”)
ws.run “””%AppData%\PulseAudio\bin\pulseaudio.exe”” –exit-idle-time=-1″,0
The extra quotes were needed since my login name has a space in it.
Good point, Thank you Ben
Thanks so much for this tutorial.
You are missing one thing in the section on pulseaudio, namely that one should run
sudo sed -i ‘s/xenial/trusty/’ /etc/apt/sources.list.d/aseering-ubuntu-wsl-pulseaudio-xenial.list
right after adding the repository.
Cheers
Jesper
Hi Jesper, thank you for your comment.
The instruction above is meant to work with Ubuntu 14.04. If you have Window 10 with Creators Update, then https://trzeci.eu/configure-graphic-and-sound-for-wsl-creators-update-for-ubuntu-16-04/ should be a better choice.
It seems that since Fall update dbusfix is no longer required, all you need is to ‘dbus start’
after adding and installing the patched pulse audio how do I run it?
Hi Cris,
It should run automatically after restart.
Link to install_pulseaudio.bat is broken :(
Hi Tyler, you’re right, sorry I didn’t know that GISTs urls don’t get redirect once I change github username.
Correct links:
install_pulseaudio.bat: https://gist.github.com/trzecieu/b46829b2b24c3896c63d4d1b05e2df80#file-install_pulseaudio-bat
Somehow upgrade to WordPress 5 has messed up post editing, but it should be fine now.
Cheers!