Installing Debian on Windows 10/11 using WSL from the command line

Installing Debian on Windows 10/11 using WSL from the command line

I have been using WSL for some time now, and with it Ubuntu on my Windows machine, but since I switched to WSL2, the startup time has increased from "instant" to 10 seconds.

It wouldn't let me reset it to WSL1, so if I'm going to reinstall WSL for this anyway, I'll see what other distributions are available besides Ubuntu. Because there are.

If you've been reading my blog for a long time, you've probably seen me mention that I'm using Windows 10 LTSC. This has many advantages (and disadvantages), I don't intend to go into them in this article.

One of those disadvantages (for some, for me it's an advantage) is that it doesn't have a Microsoft Store. And if you want to use a distribution other than the default Ubuntu, you will need it. Right? No.

So why did I choose Debian?

  1. For one thing, all my servers are running Debian (including Raspberry Pi), so it's handy.

  2. Secondly, because of its size. If you look at the size in the MS Store linked above, you can currently see that Ubuntu will download 608MB, while Debian requires only 93.5MB. That is a significant difference.
    Used storage after the installation with Ubuntu:WSL Ubuntu size

    Meanwhile the Debian uses:
    WSL Debian size

    Both configured the same way.

The installation of Debian is relatively simple, but it's hard to find how to do it without the MS Store. That is one of the reasons for this article :)

Let's get started!

  1. Open a CMD, but with a normal user, no admin rights required.

  2. Set WSL1 as a default:
    wsl.exe --set-default-version 1

  3. List all available distributions:
    wsl.exe --list --online

  4. If you want to install Debian, do so:
    wsl.exe --install -d Debian

  5. Set up your new user by entering your username (in lower case only!) and password twice.

  6. You're in the Debian. Great! You're almost done.

  7. Update your system by running:
    sudo apt update && sudo apt upgrade -y

  8. Remember to pin the icon to the taskbar:
  9. If you'd like to check the list of installed distributions, run this command in CMD:
    wsl.exe -l -v

 

Extra settings

From now on I will only write down what was important for me to get a usable system. You can use the system without these, but if you want to SSH to another machine from here, they will speed things up considerably.

  1. I don't want to write an article on SSH config, there are good sites for that, e.g. this one. However, to get the TAB autocomplete to work, you need to put these up:
    sudo apt install openssh-client bash-completion

  2. To use sudo without password, the /etc/sudoers file must be edited:
    sudo nano /etc/sudoers
    And replace the line starting with "%sudo" with this:
    %sudo ALL=(ALL) NOPASSWD:ALL

  3. Use "magic" command as an ultimate updater, and add date to the history by editing
    nano /etc/bash.bashrc
    add to the bottom:
    alias magic='sudo apt update && sudo apt dist-upgrade --autoremove -y'
    HISTTIMEFORMAT="%Y-%m-%d %T "

  4. I like to scripting in ksh, so install it:
    sudo apt install ksh

  5. And I also use these tools:
    sudo apt install curl wget

  6. The systemd enabled by default. However, since I don't use it, I disabled it to save resources:
    sudo nano /etc/wsl.conf

    And add these lines:
    [boot]
    systemd=false

 

 

Comments