====== Windows Subsystem for Linux ======
===== Instalace WSL a Linux distribuce =====
==== Instalace WSL ====
{{:private:poznamky:windows:wsl01.png?400|}}
==== Instalace Linux Distribuce - Debian ====
Instalace z Microsoft Store
{{:private:poznamky:windows:wsl02.png?400|}}
==== Základní konfigurace ====
- nový uživatel - **winbck**
- aktualizace pod účtem **root**
**Nastavení default uživatele**\\
https://www.tenforums.com/tutorials/128152-set-default-user-windows-subsystem-linux-distro-windows-10-a.html
sudo su -
apt update
apt upgrade
apt install vim rsync ssh
===== SSH =====
port 2210
==== Automatické spuštění ssh služby ====
https://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11#how-to-automatically-start-ssh-server-on-boot-on-windows-subsystem-for-linux
%sudo ALL=NOPASSWD: /etc/init.d/ssh start
Put to the ''shell:Startup'' folder bat file with the content:
powershell.exe "& 'C:\Windows\System32\bash.exe' -c 'sudo /etc/init.d/ssh start'"
==== Start WSL - bez přihlášení - no login ====
Start WSL on boot without login\\
https://www.reddit.com/r/bashonubuntuonwindows/comments/1716np4/start_wsl_on_boot_without_login/
I found that you have to keep a WSL session (started by wsl.exe, some process that's invoked by SessionLeader in pstree) running, otherwise WSL simply quits after some time.
My solution (WSL2 on Windows 11):
(optional) enable systemd in /etc/wsl.conf (for starting various services automatically, such as sshd, cron, rsyslogd, etc.)
get nircmd fom https://www.nirsoft.net/utils/nircmd.html
write a batch which has: @start /b \path\to\nircmd.exe execmd wsl ~
Use Task Scheduler to start the batch (when system starts)
===== Problém se spuštěním nainstalované distribuce =====
Po spuštění nového terminálu příksazem ''bash'' se objeví hláška ''"No installed distributions when there are indeed distros installed"''
Pomohlo zastavit a znovu spustit službu pod kterou běží WSL.
net stop LxssManager
net start LxssManager
===== Ověření nainstalované distribuce =====
wslconfig /list /all
Windows Subsystem for Linux Distributions:
Debian (Default)
===== Calling a PowerShell Script from WSL =====
https://www.raymondcamden.com/2017/09/25/calling-a-powershell-script-from-wsl
===== Windows 11 =====
Kromě funkce WSL je potřeba zapnout funkci **Platforma virtuálního počítače**
{{:private:poznamky:windows:pasted:20240305-213151.png}}
To fix the WSL install error 0x80370114
https://github.com/Microsoft/WSL/issues/3054#issuecomment-705991287
===== WSL - systemd =====
https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/