1. Debian GNU/Linux for WSL

1.1. Installation

  • Note: Enabling the Virtual Machine Platform feature will make VirtualBox virtual machines dead slow.

  • Note: The Virtual Machine Platform feature is only needed for WSL 2.

  • Enter the following commands at a Command Prompt with administrative privileges.

    wsl.exe --distribution Debian --install
  • Restart the computer.

  • Note: The WSL2 Linux kernel update package for x64 machines is only needed for WSL 2.

  • Run the wsl_update_x64.msi file.

    • Click Next.

    • Click Finish.

  • Enter the following commands at a Command Prompt with standard privileges.

    wsl.exe --set-default-version 1 # WSL 1
    wsl.exe --set-default-version 2 # WSL 2
  • Enter the following commands at a Command Prompt with administrative privileges.

    wsl.exe --set-default-version 1 # WSL 1
    wsl.exe --set-default-version 2 # WSL 2
  • Start Microsoft Store.

  • Search for Debian.

  • Select the Debian app.

  • Click Get.

  • Click No, thanks to skip signing in with Microsoft.

  • Wait for the download and installation to finish.

  • Close Microsoft Store.

1.2. First time launch

  • Select Start > Apps > Debian.

    Enter new UNIX username:        delta
    New password:                   ******** (level 2)
    Retype new password:            ******** (level 2)
  • Enter the following commands at a Command Line.

    cat /etc/debian_version         # 11.6
    uname -a
    uname -r                        # 4.4.0-19041-Microsoft         # WSL 1
    uname -r                        # 4.19.128-microsoft-standard   # WSL 2
    exit

1.3. WSL 1 vs WSL 2

  • Enter the following commands at a Command Prompt with standard privileges.

    wsl.exe --list --all --verbose
    wsl.exe --set-version Debian 1  # Convert Debian app from WSL 2 to WSL 1
    wsl.exe --set-version Debian 2  # Convert Debian app from WSL 1 to WSL 2
  • Enter the following commands at a Command Prompt with administrative privileges.

    wsl.exe --list --all --verbose
    wsl.exe --set-version Debian 1  # Convert Debian app from WSL 2 to WSL 1
    wsl.exe --set-version Debian 2  # Convert Debian app from WSL 1 to WSL 2

1.4. Remote login

  • Enter the following commands at a Command Prompt.

    
    delta-putty Administrator@SMRUWS-IT11
    delta-putty -P <ssh port> Administrator@tbhf-web-mrm
    putty.exe Douwe@localhost
    
    bash.exe                                        # Start default distro with default user.
    wsl.exe --distribution Debian                   # Start distro "Debian" with default user.
    wsl.exe --user root                             # Start default distro with user "root".
    wsl.exe --distribution Debian --user root       # Start distro Debian with user "root".
    
    cd
    
    exit
    exit

1.5. Configuration

  • Enter the following commands at a Command Line.

    # Prevent "ping: socket: Operation not permitted" error.
    ping 8.8.8.8
    ping www.google.com
    
    sudo getcap /bin/ping
    sudo setcap cap_net_raw+p /bin/ping
    sudo getcap /bin/ping
    
    ping 8.8.8.8
    ping www.google.com
    # Proxy configuration.
    sudo su -
    echo 'Acquire::http::Proxy "http://10.10.1.170:8080";'  >> /etc/apt/apt.conf.d/proxy.conf
    echo 'Acquire::https::Proxy "http://10.10.1.170:8080";' >> /etc/apt/apt.conf.d/proxy.conf
    cat /etc/apt/apt.conf.d/proxy.conf
    exit
    
    # Updates.
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    sudo apt-get autoremove
    sudo apt-get autoclean
    cat /etc/debian_version         # 11.6
    # Install Delta Linux Tools.
    sudo apt-get --yes install openssh-client       # Needed for scp.
    scp -p delta@10.10.1.2:/media/Windows/Software/_Delta/delta-linux-tools-#.#.#-1-all.deb .
    sudo dpkg -i delta-linux-tools-#.#.#-1-all.deb
    
    sudo scp -p root@10.10.1.2:/root/id_rsa-auto /root
    
    # Configuration with Delta Linux Tools.
    sudo delta config apt 10.10.1.170:8080  # Configure apt repositories with proxy server.
    export http_proxy=http://10.10.1.170:8080
    export https_proxy=http://10.10.1.170:8080
    sudo delta config bash 10.10.1.170:8080 # Configure bash shell with proxy server for each user.
    sudo delta config cron                  # Configure cron jobs.
    sudo delta config editor                # Set default editor to vim.tiny for each user.
    sudo passwd                             # Set root password.
    sudo delta config sudo                  # Configure sudo for each user.
    
    sudo delta install basic-tools          # Install basic commands like curl and wget.
    
    sudo delta setup git                    # Install and configure git.
    sudo delta setup vim                    # Install and configure vim editor for each user.
    exit                                    # Log off.
    # ???
    su -
    locale -a
    locale
    
    update-locale LANG=en_US.UTF-8
    update-locale LC_ALL=""
    
    # Restart WSL.
    sudo su -
    locale -a
    locale

1.6. Backup and Restore

  • Enter the following commands at a Command Prompt.

    wsl.exe --shutdown
    wsl.exe --list --all --verbose
    wsl.exe --export Debian Debian-YYYYMMDD.tar
    
    wsl.exe --unregister Debian
    wsl.exe --list --all --verbose
    
    wsl.exe --import Debian %LocalAppData%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState C:\Users\Douwe\Debian-20210114.tar --version 1
    wsl.exe --import Debian %LocalAppData%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState C:\Users\Douwe\Debian-20210114.tar --version 2
    # Change the default user to "delta" for the "Debian" distribution.
    debian.exe config --default-user delta
    wsl.exe --list --all --verbose

1.7. Uninstallation

  • Right-click Start > Apps > Debian and select Uninstall.

  • Enter the following commands at a Command Prompt.

    wsl.exe --list --all --verbose
    wsl.exe --unregister Debian
    wsl.exe --list --all --verbose
    
    
    dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart
    dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
  • Restart the computer.

  • Uninstall Windows Subsystem for Linux Update from Programs and Features.

  • Uninstall Windows Subsystem for Linux WSL Preview from Programs and Features.

1.8. IT Documentation

  • Enter the following commands at a Command Line.

    sudo apt-get --yes install devscripts           # Needed for checkbashisms.
    sudo apt-get --yes install gawk                 # Needed for ansi2html.
    sudo apt-get --yes install make
    sudo apt-get --yes install python               # Needed for make.
    sudo apt-get --yes install shellcheck           # Needed for shellcheck.
    sudo apt-get --yes install fonts-thai-tlwg      # Thai fonts.
    
    sudo -E delta setup ansi2html                   # Needed for search.
    sudo delta setup apache                         # Install and configure apache http server.
    sudo delta setup fonts                          # Install Myanmar Text font files.
    sudo delta setup jre-headless                   # Needed for diagrams support.
    sudo delta setup php                            # Needed for search.
    sudo delta setup ruby                           # Needed for asciidoctor.
    sudo delta setup samba Other$                   # Create hidden Other$ share.
    
    sudo -E delta config vim powershell             # Add powershell syntax highlighting.
    
    sudo -E delta setup asciidoctor
    sudo -E delta update asciidoctor
    
    which asciidoctor asciidoctor-pdf
    asciidoctor --version                           # 2.0.18
    asciidoctor-pdf --version                       # 2.3.4
    
    mkdir -p ~delta/github/git/delta-software-labs
    cd ~delta/github/git/delta-software-labs
    git clone https://delta-software-labs@github.com/delta-software-labs/Documentation.git
    # Type the GitHub - PAT (Personal Access Token) stored in KeePass Password Manager.
    
    cd ~delta/github/git/delta-software-labs/Documentation
    make clean; make
    make check
  • Start Debian.

  • Start Apache2.

    • sudo service apache2 start

1.9. Build

Make sure the path to the WSL Distro Launcher files does not contain spaces to prevent the MSBUILD : error MSB1008: Only one project can be specified. error.

  • Custom Made: Create a custom Debian GNU/Linux install.tar.gz file.

  • Ready Made: Extract the install.tar.gz file from the TheDebianProject.DebianGNULinux_1.0.0.0_x64__76v4gfsz19hv4.Appx file.

  • Download WSL Distro Launcher.

  • Extract the WSL-DistroLauncher-master.zip archive to the D:\Tmp folder.

  • Select Start > Programs > Visual Studio 2017 > Visual Studio Tools > Developer Command Prompt for VS 2017.

  • Enter the following commands at the Command Line.

where MSBuild
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
cd /d D:\Tmp\WSL-DistroLauncher-master
if not exist x64\ mkdir x64
copy /y ..\DistroLauncher-Appx_TemporaryKey.pfx DistroLauncher-Appx
copy /y ..\install.tar.gz x64
  • Enter the following commands at a PowerShell Command Prompt.

$File = "DistroLauncher\DistributionInfo.h"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "MyDistribution", "SMRUDebian"
$Content = $Content -replace "My Distribution", "SMRU Debian"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher\DistroLauncher.vcxproj"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "10.0.16299.0", "10.0.17134.0"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher-Appx\DistroLauncher-Appx.vcxproj"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "10.0.16299.0", "10.0.17134.0"
$Content = $Content -replace "MyDistro", "SMRUDebian"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher-Appx\MyDistro.appxmanifest"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "DistroOwner", "SMRU WSL Debian Distro Launcher Appx"
$Content = $Content -replace "MyDistro", "SMRUDebian"
$Content = $Content -replace "My Linux Distro", "Debian GNU/Linux - SMRU"
$Content = $Content -replace "My Own Distro Launcher", "Launcher for Debian GNU/Linux - SMRU"
[System.IO.File]::WriteAllText($File, $Content)
$File = "DistroLauncher\DistributionInfo.h"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "MyDistribution", "Debian9SMRU"
$Content = $Content -replace "My Distribution", "Debian 9 SMRU"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher\DistroLauncher.vcxproj"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "10.0.16299.0", "10.0.17134.0"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher-Appx\DistroLauncher-Appx.vcxproj"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "10.0.16299.0", "10.0.17134.0"
$Content = $Content -replace "MyDistro", "Debian9SMRU"
[System.IO.File]::WriteAllText($File, $Content)

$File = "DistroLauncher-Appx\MyDistro.appxmanifest"
$Content = [System.IO.File]::ReadAllText($File)
$Content = $Content -replace "DistroOwner", "SMRU WSL Distro Launcher Apps"
$Content = $Content -replace "MyDistro", "Debian9SMRU"
$Content = $Content -replace "My Linux Distro", "Debian GNU/Linux - SMRU"
$Content = $Content -replace "My Own Distro Launcher", "Launcher for Debian GNU/Linux - SMRU"
[System.IO.File]::WriteAllText($File, $Content)
  • Enter the following commands at a Command Line.

copy /y DistroLauncher-Appx\MyDistro.appxmanifest DistroLauncher-Appx\SMRU9Debian9.appxmanifest
MSBuild.exe DistroLauncher.sln /t:Clean /m /nr:true /p:Configuration=Release;Platform=x64
MSBuild.exe DistroLauncher.sln /t:Clean /m /nr:true /p:Configuration=Release;Platform=x64
MSBuild.exe DistroLauncher.sln /t:Build /m /nr:true /p:Configuration=Release;Platform=x64       # 1st time, fails
MSBuild.exe DistroLauncher.sln /t:Build /m /nr:true /p:Configuration=Release;Platform=x64       # 2nd time, succeeds
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.72

Created appx in D:\Tmp\WSL-DistroLauncher-master\x64\Debug\DistroLauncher-Appx\
set /p Password="Enter the level 2 password: "
signtool.exe sign /a /f DistroLauncher-Appx\DistroLauncher-Appx_TemporaryKey.pfx /fd SHA256 /p %Password% AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Test\DistroLauncher-Appx_1.0.0.0_x64.appx
Done Adding Additional Store
Successfully signed: AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Debug_Test\DistroLauncher-Appx_1.0.0.0_x64_Debug.appx
dir AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Debug_Test
dir AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Test
AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Debug_Test\DistroLauncher-Appx_1.0.0.0_x64_Debug.appx
AppPackages\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Test\DistroLauncher-Appx_1.0.0.0_x64.appx
  • Uninstall any previous installation.

  • Check Launch when ready.

  • Click Install.

  • Type smru for new UNIX username.

  • Type the level 2 password.