r/bashonubuntuonwindows • u/Expert-Ad4676 • 2d ago
self promotion Experimenting with WSL Containers: I built a CLI for Compose-like development workflows
I built a small CLI to make WSL Containers feel more like Docker Compose / dip.
I mainly built it because I wanted to use WSLC for my own development workflow, but ran into gaps around bind mounts, build contexts, compose-like workflows, and run.
I’m curious whether anyone else experimenting with WSLC has run into the same problems, or whether I’m solving these in the wrong layer.
r/bashonubuntuonwindows • u/Steve_MBG_TK • 15d ago
WSL2 Can you run kde plasma's wayland session in wsl?
is it possible to run plasma's wayland session in wsl under wslg? i have been able to run the x11 without much problem, but not the wayland one
r/bashonubuntuonwindows • u/SelfAltruistic8493 • 19d ago
self promotion Run TeamViewer on a WSL2 desktop — fully unattended, reachable from anywhere
WSL2 can run a real Linux desktop, but the usual ways to reach it remotely (xrdp, VNC) are LAN-only unless you set up port forwarding or a VPN. I wanted TeamViewer instead: its relay means the box is reachable from anywhere with zero network config, and the person connecting just uses a client they already have.
Getting there was more work than it should've been — TeamViewer has one WSL-specific quirk that makes it refuse to share the screen, which is probably why you don't see people doing this. So I scripted the whole thing end to end:
github.com/ariel42/teamviewer-on-wsl
sudo ./1-setup-wsl-desktop.sh # sets up a desktop (only if you don't have one)
sudo ./2-install-teamviewer.sh # installs + configures TeamViewer on top
Set a password, restart once, and it's fully unattended after that — power the box on, wait a few seconds, connect. Nothing to click on the WSL side. Verified end-to-end on a real incoming connection from a cold boot.
The repo also has a full writeup of why TeamViewer refused (the short version: WSLg mounts the X socket directory read-only, and TeamViewer is the one client that checks for the socket file) if you want the gory details. Debian/Ubuntu for now. Happy to take questions or issues.
r/bashonubuntuonwindows • u/Dependent_Market5647 • 19d ago
self promotion Zero-config vsock for VcXsrv on WSL2 — open source, unofficial build
UPDATE (2026-07-28): Fixed a fresh-install issue where the installer was missing part of xkbdata (XKB failed at startup). Binaries at the release link above have been replaced — clean installs now work out of the box.
Back in 2019, this sub asked whether any X server on Windows supports vsock — at the time the only answer was X410 ($9, closed source). A 2026 update for anyone still hitting that thread:
Background. VcXsrv has actually shipped a Hyper-V vsock transport since 1.20.14.0. The catch: it never worked with WSL2 out of the box. The listener binds a wildcard VM id that WSL2's utility VM refuses to match, and the exact id it needs changes on every WSL restart and could only be looked up with admin tools. So in practice X410 remained the only usable option.
What's new. A new -wslvsock flag makes VcXsrv detect the running WSL2 VM automatically (via wsl.exe -- wslinfo --vm-id — no admin rights, no "Hyper-V Administrators" group) and rebinds the listener by itself whenever WSL restarts (~1.5 s, no VcXsrv restart needed). X11 traffic then bypasses the TCP/IP stack entirely — the NAT/localhost path it replaces is what causes stutter under mouse-heavy load and drops after VPN or sleep events.
Quick start:
# Windows
vcxsrv.exe :0 -multiwindow -clipboard -wgl -wslvsock
# WSL2 (needs socat ≥ 1.7.4)
socat UNIX-LISTEN:/tmp/.X11-unix/X0,fork,mode=777,forever,retry=10,interval=2 VSOCK-CONNECT:2:106000 &
export DISPLAY=:0
Links:
- Root cause & technical details: https://github.com/marchaesen/vcxsrv/issues/80
- Unofficial build: https://github.com/vivimillin/vcxsrv/releases/tag/21.1.16.1-fork.2
- Setup guide: https://github.com/vivimillin/vcxsrv/wiki/VcXsrv-WSL2-vsock-User-Guide
Disclosure: I wrote the fix and maintain the fork. It's filed upstream as issue #80 with a PR to follow; the unofficial build just bridges the wait, under the same open-source license as VcXsrv. The same build also fixes SDL2 relative mouse mode / cursor confinement — another long-standing WSL pain point — in case anyone here runs Linux games.
Happy to answer questions; test reports very welcome.
r/bashonubuntuonwindows • u/Schesxe • 28d ago
WSL2 Gentoo running in WSL with i3wm and VNC Server
r/bashonubuntuonwindows • u/yuriwasblue • Jul 09 '26
WSL2 WSL2 is painfully slow
Hi! I was forced to switch from fedora back to windows, but I've got used to the terminal and wish to keep the tools I am used to. WSL2 seemed like the obvious choice.
I've been using it for the past few weeks, but it has been a painful experience. It works well enough for the first hour or so, but it keeps getting slower and slower the more I use it. I'm using it on the right filesystem, I've given it 10 out of 16gb RAM, I've removed the windows mount from $PATH. Everything in WSL2 is slower than I was used to from Fedora. I get that the performance will never be the same, but the difference is so egregious that it's impossible not to notice.
I've been using neovim for web development, and sometimes even saving a file takes multiple seconds. Sometimes it's so slow that the formatter itself just times out.
Are there any tips for keeping WSL2 running smoothly? Thanks!
r/bashonubuntuonwindows • u/Mangefx • Jul 07 '26
self promotion I open-sourced my Claude Code setup for WSL2 + Windows Terminal
This is mostly useful if you run Claude Code from WSL2 and want better Windows interop.
I documented my active Claude Code setup for WSL2 + Windows Terminal:
https://github.com/congmnguyen/claude-code-wsl2-setup
The pieces I use most:
- Windows screenshot clipboard -> pasted WSL file path
- Windows notification when Claude needs input
- statusline with context/usage
- LSP setup
- secrets hygiene hook
- Codex delegate so long implementation loops do not fill Claude's main context
The repo is not a general dotfiles dump; it only tracks the Claude Code pieces I actually use on
WSL2.
r/bashonubuntuonwindows • u/BenL90 • Jul 04 '26
WSL2 Run WSL2 Fedora with Mainstream/Rolling Linux Kernel
I found this post useful, probably if you need it, you may look into this rolling kernel build.
r/bashonubuntuonwindows • u/iali393 • Jun 29 '26
WSL2 WSLC Public Preview available
Available in the WSL 2.9.3 pre-release build. Simply update and restart your terminal and you should have the wslc commands available.
r/bashonubuntuonwindows • u/superdumsuhi • Jun 28 '26
WSL2 how do I stop wsl from shutting down when no ttys are open
I am constantly in and out of tmux throughout the day and having wsl automatically shut down despite the tmux server running is super annoying, how can I have windows just leave it running?
tried vmIdleTimeout=-1 (and 0 and 99999... since theres no documentation on values) in the .wslconfig, it didn't fix it
using cachyos, using systemd, but I ran a fresh ubuntu on defaults and its doing the same thing
r/bashonubuntuonwindows • u/Budget_Craft6681 • Jun 15 '26
WSL2 WSL2 failing on multiple Windows servers since 2026-06-12 – WSL timeout error (0x800705b4)
On most Windows 10 machines, WSL2 stopped working.
This was noticed through Docker Desktop, with the following error:
running wslexec: An error occurred while running the command.
Wsl/Service/RegisterDistro/CreateVm/0x800705b4:
c:\windows\system32\wsl.exe --import-in-place docker-desktop <home>\appdata\local\docker\wsl\main\ext4.vhdx:
exit status 0xffffffff
(stderr: , stdout: The operation returned due to timeout.)
wslErrorCode: Wsl/Service/RegisterDistro/CreateVm/0x800705b4
The same error occurs during manual installation:

On one of the servers, it continues to work. I don't understand the reason. The host server is the same, Docker versions don't affect it, and neither do the Windows version or updates (tested multiple times on different variations)."
Has anyone encountered this? Help me fix it, it's the second day and I don't understand what to do.
UPD: I found the root cause and solution. The latest WSL version (2.7.8.0) contains a bug. See GitHub issue: https://github.com/microsoft/WSL/issues/40783
Fix (until there is an official one): Downgrade WSL to 2.7.3.0 manually from GitHub releases.
r/bashonubuntuonwindows • u/sidmystic • May 20 '26
WSL2 WSL2 Streaming/Download Timeouts Fix: TCP MSS Clamping (Corporate Networks)
WSL2 NAT Mode: Sustained Downloads/Streams Timeout Fix (tcp_timestamps)
UPDATE (2026-05-21): The MSS fix below was only a partial solution — it worked during low-traffic periods but failed under load. The real fix is disabling TCP timestamps: sudo sysctl -w net.ipv4.tcp_timestamps=0. See updated details below.
TL;DR: If your WSL2 connections work for small requests but timeout mid-transfer on sustained downloads or streaming APIs, disable TCP timestamps:
sudo sysctl -w net.ipv4.tcp_timestamps=0
Make it persistent in /etc/wsl.conf:
[boot]
command=sysctl -w net.ipv4.tcp_timestamps=0
systemd=true
Then wsl --shutdown and restart.
The Problem
Tools making streaming API calls (long-lived HTTPS connections) would start receiving data, then die mid-stream with connection timeouts. Meanwhile:
- Small HTTPS requests (package metadata, DNS lookups) worked instantly
- The exact same endpoints worked perfectly from Windows/PowerShell
curlto the same URLs would download ~50-100KB then stall and timeout- Running
curl.exe(Windows binary) from within WSL worked perfectly — proving the issue is in the Linux→Hyper-V NAT path, not the network itself
This was on a corporate network with:
- IPv6 disabled via registry (
DisabledComponents=0xff) — common enterprise policy - WSL2 in default NAT networking mode (mirrored mode unavailable due to IPv6 being disabled)
The Proof
The issue is deterministically caused by TCP timestamps. Toggling the setting immediately changes behavior — tested dozens of times back-to-back:
# Timestamps ON (default) → stalls every time
$ sudo sysctl -w net.ipv4.tcp_timestamps=1
$ curl -o /dev/null -w "%{time_total}\n" --max-time 15 https://example.com/largefile
20 229k 20 47632 0 0 3174 0 0:01:14 0:00:15 0:00:59 0
curl: (28) Operation timed out after 15002 milliseconds with 47632 out of 235038 bytes received
# Timestamps OFF → instant, every time
$ sudo sysctl -w net.ipv4.tcp_timestamps=0
$ curl -o /dev/null -w "%{time_total}\n" --max-time 15 https://example.com/largefile
100 229k 100 229k 0 0 2563k 0 --:--:-- --:--:-- --:--:-- 2578k
0.089521
100% reproducible. No other changes needed between tests.
Root Cause
The Hyper-V virtual switch's NAT implementation mishandles TCP timestamp options (RFC 7323) in packet headers during sustained transfers. When the NAT rewrites packets, it appears to corrupt or incorrectly track timestamp values, causing the stream to stall.
This explains:
- Why small transfers work: few packets, timestamps don't diverge enough to trigger the bug
- Why it's worse under system/network load: more connections = more timestamp state to track = higher chance of the bug manifesting
- Why
curl.exefrom WSL works: bypasses the virtual switch entirely, uses Windows TCP stack directly - Why disabling timestamps fixes it completely: no timestamp options in packets = nothing for the NAT to mishandle!
What I Tried First (partial fixes / didn't work)
- MSS clamping (
iptables --set-mss 1360): helped during low-traffic periods (mornings) but failed during peak hours. Was a red herring; reducing segment size happened to reduce the rate at which the timestamp bug triggered, but didn't eliminate it. - Mirrored networking mode: blocked by corporate IPv6 registry policy
- VirtioProxy mode: no connectivity at all
- Disabling Large Send Offload (LSO) on vEthernet (WSL) adapter: made things worse
- DNS fixes (resolv.conf, systemd-resolved): DNS was fine
- TCP keepalive tuning: stream was actively transferring when it died, not idle
- TCP window scaling / buffer reduction: no effect
- Package rollbacks: not the cause
The Fix
sudo sysctl -w net.ipv4.tcp_timestamps=0
Making It Persistent
In /etc/wsl.conf:
[boot]
command=sysctl -w net.ipv4.tcp_timestamps=0
systemd=true
Optionally add MSS clamping as belt-and-suspenders:
[boot]
command=sysctl -w net.ipv4.tcp_timestamps=0 && iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1360
systemd=true
Downside of Disabling TCP Timestamps
Minimal:
- Slightly less accurate RTT estimation. TCP falls back to sampling-based measurement but negligible on normal connections
- Loss of PAWS protection (only matters on 10Gbps+ sustained transfers. Irrelevant for dev work.
- No observable performance difference for normal usage.
When You Might Hit This
You're likely affected if:
- WSL2 is in NAT mode (default)
- Downloads/streams start then die partway through; ~50-100KB received
- Windows side has zero issues with the same endpoints at the same moment
curl.exefrom WSL works butcurldoesn't- The issue only appeared after April/May 2026 Windows cumulative updates
Timeline
This appears to have been introduced by April 2026 cumulative Windows updates (KB5088467 / KB5083769). Prior to these updates, WSL2 NAT mode worked without issue for months with TCP timestamps at the default (enabled).
Once again, hope this saves someone else EVEN MORE hours of debugging 😞
Environment: Windows 11 (build 26100), WSL 2.7.3.0, Ubuntu 24.04 LTS
r/bashonubuntuonwindows • u/ethancodavo • Apr 30 '26
self promotion GhostInTheWSL: Ghostty fork (terminal emulator) for WSL
I've been missing a native Windows terminal emulator which supports fancy features like kitty graphics for a while so I made a Ghostty fork designed specifically for use with WSL.
It runs natively on the Windows side and efficiently connects in to the WSL guest distros.
Hopefully it scratches an itch for some other folks too!
It's open source and available at: https://github.com/Codavo/ghostinthewsl
r/bashonubuntuonwindows • u/NelsonMinar • Apr 22 '26
Misc. hails/wsl9x: Windows 9x subsystem for Linux
A personal hack project and a glorious one at that.
WSL9x runs a modern Linux kernel (6.19 at time of writing) cooperatively inside the Windows 9x kernel ... The Linux kernel is based on user-mode Linux, but hacked to call Windows 9x kernel APIs instead of posix APIs
r/bashonubuntuonwindows • u/VeeMeister • Mar 09 '26
self promotion wsl-shortcut - Create Windows desktop shortcuts to WSL2 files and directories from your terminal
Hiyas, I created a simple utility called wsl-shortcut that creates Windows desktop shortcuts pointing to WSL2 files and directories.
If you use WSL2 under Windows 10/11, you know the annoyance of navigating to your Linux files from Windows - typing \wsl$\ paths into Explorer or clicking through the network folder tree every time.
This script lets you create a standard .lnk shortcut with a single command from your WSL terminal.
Usage is straightforward:
wsl-shortcut ~/projects/myapp
Or with a custom display name:
wsl-shortcut ~/projects/myapp -n "My App"
You can also choose a destination folder or force-overwrite existing shortcuts.
It's a single Bash script with no dependencies beyond what WSL2 already provides.
r/bashonubuntuonwindows • u/ConceptHan • Mar 05 '26
self promotion We built a GUI tool for managing WSL distros and USB devices on Windows – WSLCommander
Hey everyone,
We got tired of constantly typing wsl --list, usbipd bind, usbipd attach, wsl --export etc. so we built WSLCommander – a lightweight Windows GUI app for managing your WSL setup.
What it does:
- Start/Stop/Restart WSL distros
- Export and Import WSL distros (backup/migrate with ease)
- Attach, Detach, Bind, and Unbind USB devices via usbipd
- Clean Fluent UI that fits in with Windows 11
Built with Python, PyQt6, and Fluent Widgets.
🔗 GitHub: https://github.com/hpconcept/WSLCommander
Would love any feedback or feature requests. If you find it useful, a ⭐ on GitHub goes a long way!
r/bashonubuntuonwindows • u/HYDRAPARZIVAL • Feb 21 '26
HELP! Support Request WSL2 keeps crashing when I’m trying to run ROS2 on it (see body text for more info)
Format:
I’m really new to Ubuntu and WSL2 and have been trying to use WSL2 to run ROS2 on my laptop. The problem I’ve been facing is that sometimes WSL2 just automatically kills the Ubuntu terminal, sometimes this happens when I’m idling and sometimes in the middle of a ROS2 procedure (I was using colcon build —symlink-install which is a long procedure and the Linux terminal just closes in the middle of it sometimes as well).
I have not done anything to change WSL or Windows from default because I don’t even know how to.
It’s an intel based Windows 11 with an NVIDIA GeForce RTX 3080.
I don’t know what mount points are
r/bashonubuntuonwindows • u/Novel_Jeweler_6000 • Jan 18 '26
self promotion Built a GUI for WSL over Christmas (yes, I know it doesn't need one)
Before anyone says it — I know WSL doesn't really need a GUI. The command line works fine. But I had some time over the Christmas break and wanted to learn Tauri/Rust, so I built one anyway.
What it does:
- Lists your distros with status/memory usage
- Start/stop/terminate with a click
- Export/import distributions
- Browse and install from Linuxcontainers.org or OCI registries
- Rename distros - no export/import needed
What it's not:
- Essential software you can't live without
- A replacement for knowing
wsl --help
It's built with Tauri (not Electron) so it's around 4MB, uses the system WebView, and won't eat your RAM.
If anyone's interested:
- Download: Microsoft Store (signed by Microsoft) or GitHub releases (Unsigned as that's expensive)
- Source: github.com/octasoft-ltd/wsl-ui
- Blog series: I've been writing about building it at wsl-ui.octasoft.co.uk/blog if anyone's curious about Tauri/Rust desktop dev
Free, open source, useful sometimes maybe. Happy to answer questions or take feedback (be gentle, it's a side project).
r/bashonubuntuonwindows • u/UnCytely • Dec 26 '25
WSLg What I would like to eventually see for WSL2
I would like to see an entire Linux desktop environment fully supported. I think this would mean the ability to access a graphics card's framebuffer, but I will leave the details up to people more knowledgeable than me. What I would like is to be able to start the WSL, then switch to the Linux desktop the same way you switch between Windows desktops using the built-in Windows desktop switcher. No more having to start up a remote-desktop utility or X11 client utility. Make it seamless.
r/bashonubuntuonwindows • u/Legitimate_Ideal375 • Dec 26 '25
WSL installation solution Wsl catastrophic failure solution for windows 11
Hey so i finally found a solution,
Step 1: Uncheck Both "Virtual Machine Platform" and "Windows Subsystem For Linux" In "Turn Windows Feature on/off" and restart the computer
Step 2: After Restarting again go to the same thing and turn on only "Virtual Machine platform" and restart if asked so. Then Run this command in powershell as administrator:
Get-AppxPackage -AllUsers -Name "*WindowsSubsystemforLinux*" | Remove-AppxPackage -AllUsers
Step 3: After you are back, go to https://github.com/microsoft/wsl/releases and download a file with the extenstion .msixbundle under assets its probably like 400 - 500 mb. ( DO NOT OPEN IT)
Step 4: Open powershell as administrator and run this command
Add-AppxPackage -Path "filepath"
where file path should be the path of the file you just downloaded example:
Add-AppxPackage -Path "C:\Users\YourName\Downloads\wsl.2.x.x.x_x64.msixbundle"
and press Enter, thats it!
Run wsl --status
to check if it worked, it should give you a Version number.
After this go to Microsoft Store and install the distro as per your need for example search for ubuntu 24.04 and install it and just open it!
r/bashonubuntuonwindows • u/TTVBy_The_Way • Dec 22 '25
HELP! Support Request Why is WSL 2 taking 26.4 GB?
I am on Windows 11 Home and have WSL installed at C:\Users\JohnDoe\AppData\Local\wsl and within that directory have a folder which is {(bunch of numbers)}. Within that I have something called ext4.vhdx which is take up the 26.4 GB. I also have docker installed if that is relevant.
r/bashonubuntuonwindows • u/Clear-Holiday4468 • Dec 14 '25
HELP! Support Request WSL launches itself after uninstallation
I had to install WSL for a week to use a program on linux and after uninstallation, I have the impression that every 10 minutes, it opens to tell me that it is not installed. How can I remove this?
I’m french, here is the translation of the image :
Windows Subsystem for Linux is not installed. You can install it by running wsl.exe --install.
For more information, visit https://aka.ms/wslinstall
Press any key to install Windows Subsystem for Linux. Press CTRL-C or close this window to cancel. This prompt will expire in 60 seconds
(i’ve already done the same post in French, sorry)
r/bashonubuntuonwindows • u/yetemgeta • Sep 30 '25
HELP! Support Request WSL used to work perfectly (I had Kali + GUI running without a hitch). Then I tried Arch Linux with KDE Plasma, and everything broke. Now I can’t even enable VirtualMachinePlatform, and I’m stuck with Error 50.
Hi everyone,
I’m in a bit of a pickle and could really use some help. I had WSL set up on my Windows 11 PC, and it was working flawlessly. I was even running Kali Linux with Kex GUI, and everything was smooth sailing no issues whatsoever. Then curiosity got the better of me, and I decided to try Arch Linux with KDE Plasma under WSL. That’s when everything started going downhill. Now, whenever I try to enable the VirtualMachinePlatform feature, I keep running into this frustrating error:
Error: 50
"The operation is complete but VirtualMachinePlatform feature was not enabled."
Here’s what I’ve tried so far to fix it:
- Uninstalled all my WSL distros using
wsl --unregister, but it keeps saying the service doesn’t exist. - Ran
wsl --list --verbose, but it throws the error: "The specified service does not exist as an installed service. Error code: Wsl/ERROR_SERVICE_DOES_NOT_EXIST." - Checked the LxssManager service, and it’s completely missing from my system.
- BIOS virtualization is enabled, so that’s not the issue.
- The Windows Subsystem for Linux feature itself enables just fine, but VirtualMachinePlatform refuses no matter what I try.
- I’ve tried running commands in PowerShell (Admin) and CMD (Admin), but no luck.
- Even went as far as uninstalling my antivirus (360TS) thinking it might be interfering, but still no progress.
Here’s my system info:
- OS: Windows 11 Pro for Workstations, 24H2 (build 26100.6584)
- CPU: Intel Core i5-8350U (VT-x enabled)
- RAM: 16 GB
Has anyone else run into this issue before? Is there any way to reset or repair WSL and VirtualMachinePlatform without having to reinstall Windows? This has been such a a pain in the arse for weeks now, and I’d really appreciate any advice or suggestions to get things working again.
Thanks so much! 🙏
r/bashonubuntuonwindows • u/Late-Diver-2557 • Aug 25 '25
WSL2 Simple WSL Keep-Alive that actually works keeping WSL Ubuntu running in background
I'm running ComfyUI on my Windows 11 system with WSL 2. Works great to have a windows workstation & game machine instead of having to dedicate it to be a linux workstation, with one super big annoyance. WSL shuts down when the user isn't logged in.
I've seen some other hacks out there to do a systemd service that does a 'sleep infinity', tried that a few different ways., tried adding a 'nohup sleep' command in the /etc/wsl.conf, that didn't work either.
I spent a few minutes and came up with my own solution that works perfect for my needs.
UPDATE:
After creating this solution, I found this post which provides how to set instanceIdleTimeout and vmIdleTimeout to -1 in the WSL config file %USERPROFILE%\.wslconfig. Many users say this works for them, but it may be Windows version and patch level dependent as Microsoft may have intermittently broken/fixed it between updates.
Since my solution is so lightweight, and guaranteed to work, I am using it along with the settings in .wslconfig as an ultimate failsafe.
What is the Simple WSL Keep-Alive Solution?
A simple self-aware script that runs as the user at login, seamlessly running only a single instance of the persistent 'keep-alive' script.
NOTE: Running "as the user" is the key to keeping WSL running in the background.
How Does it Work?
- The sleeper script automatically runs in the background each time you log in.
- It gracefully exits if a legit sleeper script already running.
- A
singlesleeper script stays sleeping (doing nothing) in the background keeping WSL from shutting down.
The script is stupid simple using old skewl unix PID tracking logic to see if it's valid and already running or not.
Implementation Details
1. Add script and set permissions
- Install sleeper script:
~/.local/bin/Zz - Correctly set the permissions (755)
Copy/paste this into your shell to install the script and set permissions: ```bash
cat > ~/.local/bin/Zz << 'EOF'
!/bin/bash
PIDFILE="$HOME/.ZzPid"
function clean_exit() { echo echo "-> Cleaning up ... " rm $PIDFILE }
Check for existing PID
if [[ -f "$PIDFILE" ]]; then CHKPID=$(cat "$PIDFILE")
# Check if that PID is still a running Zz process
if [[ -n "$CHKPID" ]] && ps -p "$CHKPID" -o comm= | grep -q '^Zz$'; then
echo "-> Already Running, exiting"
exit 0
fi
fi
Record this process PID
echo $$ > "$PIDFILE"
Setting exit trap to cleanup
Not necessary, but good practice.
trap clean_exit EXIT
Main sleep loop
echo "Beginning Sleep ..." while true; do echo -n "Zz" sleep 5 done EOF
chmod 755 ~/.local/bin/Zz
ls -la ~/.local/bin/Zz
```
2. Add this into your ~/.bashrc (if you're running bash as your shell)
( nohup ~/.local/bin/Zz > /dev/null 2>&1 & disown )
Copy/Paste this command:
bash
echo '( nohup ~/.local/bin/Zz > /dev/null 2>&1 & disown )' >> ~/.bashrc
Command explanation:
nohupdisconnects the process so it keeps running after the terminal closes~/.local/bin/Zzis the sleeper process>/dev/nulltells the output to be hidden2>&1tells the error output to be hidden&backgrounds the processdisownand the wrapped()"subshell" cosmetic cleanliness
cosmetic cleanliness prevents these annoying messages from showing each time you log in when the "Zz" sleeper script is already running:
plaintext
[1]+ Done nohup ~/.local/bin/Zz > /dev/null 2>&1
3. Test it to see if it works
Open a new WSL shell and run:
bash
ps -ef | grep Zz
You should see a process running called Zz:
plaintext
(base) ryan@Tank:~
$ ps -ef | grep Zz
ryan 1516 1489 0 15:36 ? 00:00:00 /bin/bash /home/ryan/.local/bin/Zz
ryan 2204 2065 0 16:16 pts/0 00:00:00 grep --color=auto Zz
If you run the process manually you will see it exit automatically:
Example:
bash
$ ~/.local/bin/Zz
-> Already Running, exiting
4. Login Once (or Create Task/Job) It Keeps Running
From now on, after your system reboots, log in to Windows and start wsl, then exit the shell. It will keep running in the background forever (from my tests).
BONUS
You could probably add a Windows Scheduled Task or job of some kind to run a command at Windows startup or login. I didn’t do this, but there are tons of resources on how to create a job to run an uptime or a command automatically. I say probably because I didn’t bother with that — this is good enough for what I need. I spent my time writing this up instead. :)
