Future-proof your skills with Linux, Python, vim & git as I share with you the most timeless and love-worthy tools in tech through my two great projects that work great together.

Created Windows Shortcut To Start Linux Jupyter on LXD

This blog post explains how I created a Windows Shortcut (LXD.lnk) to start a Jupyter server on WSL, getting around API limitations and ensuring the command-line parameters of WSL and LXD work properly. With this shortcut, I can easily visit http://localhost:8888 and start the Jupyter server. Learn how I did it in this post!

Create a Windows Shortcut to Easily Access Linux Jupyter on LXD

By Michael Levin

Tuesday, September 20, 2022

Okay, I added LXD.lnk to the WSL2LXD repo. It’s very simple:

wt PowerShell -c "wsl -d Ubuntu-18.04"

This works because when the Ubuntu 18.04 .bash_login script is:


And this is a program in /usr/local/sbin on WSL:

        lxc jupyterstart 2>/dev/null
        sleep 1
lxc exec jupyter -- su --login ubuntu

And now this is actually using the alias feature of lxc which you can see when logged into just WSL with lxc alias list. Anyway, jupyerstart is an alias for:

exec jupyter -- su --login ubuntu -c /usr/local/sbin/jupyterstart

And now there’s one more /usr/local/sbin file in the picture, but this one is under LXD and just starts the Jupyter server:

cd ~/repos
screen -wipe >/dev/null 2>&1
if ! screen -list | grep -q "jupyter"; then
    screen -dmS jupyter /home/ubuntu/py310/bin/jupyter lab --ip --port 8888 --no-browser --ServerApp.password='[long hash deleted]'
echo "Visit http://localhost:8888"

Pshwew! There’s a lot of getting around API limitations going on here by use of sbin commands. There’s a temptation to make bash script one-liners and feed them on the command-line parameters of wsl and lxd, but that generally doesn’t work. If it’s not permission problems then it’s semicolon parsing. It turns out that dropping magic little sbin commands into place and calling them on the command-line seems to always work.