“Unrooting” WSL…

WSL starts as root user be default.

Here’s how to ensure it runs as a “non-root user” (assumedly already created), which you then have to su and/or sudo <something> to act as root:

  • either/and:
    • modify a shortcut or change Windows Terminal’s Profile to set the distribution (if required) and the user name, and starting in the user’s home directory:
      • wsl -d <distro> -u <user> -cd ~
    • edit /etc/wsl.conf to always start with a specific user:
      • [user]
        default=<user>

Simple! (Not!)

Upgrading WSL2 Ubuntu LTS 22.04 to LTS 24.04…

After fixing WSL networking issues, I had to upgrade the Ubuntu LTS instance… The sequence should have been:

  • apt update
  • apt upgrade -y
  • apt dist-update
  • lsb_release -a   # to confirm version before upgrade
  • do-release-upgrade
  • lsb_release -a   # to confirm version after upgrade

But, as per usual, I hit another issue attempting to upgrade (i.e. while running do-release-upgrade):

error: cannot list snaps: cannot communicate with server: Get "http://localhost/v2/snaps": dial unix /run/snapd.socket: connect: no such file or directory

A quick ‘net search brought up the point that snapd was not running…

Continue reading