WSL2: Difference between revisions

From Wiki
mNo edit summary
mNo edit summary
Line 63: Line 63:
<pre>
<pre>
mount -t drvfs '\\server\share' /mnt/share
mount -t drvfs '\\server\share' /mnt/share
</pre>
== Docker in WSL ==
* install docker on linux
* add to ~/.bashrc
<pre>
# Start Docker daemon automatically when logging in if not running.
RUNNING=`ps aux | grep dockerd | grep -v grep`
if [ -z "$RUNNING" ]; then
    sudo dockerd > /dev/null 2>&1 &
    disown
fi
</pre>
</pre>



Revision as of 12:59, 19 November 2021

Installation

  1. Run from Admin-PowerShell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
  1. Update WSL Kernel
  2. Restart
  3. Install Ubuntu from Microsoft Store

Using New Windows Terminal

  • profiles.json
    • set defaultProfile to Ubuntu
    • for linux home dir:
"commandline" : "wsl.exe ~ -d Ubuntu-18.04",


 "profiles":
    [
        {
            "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
            "source": "Windows.Terminal.Wsl",
            "name": "Ubuntu-18.04",
            "commandline": "wsl.exe ~ -d Ubuntu-18.04",
            "fontSize": 10
        },
        {
            "name": "server1",
            "commandline": "wsl.exe ~ -d Ubuntu-18.04 ssh server1",
            "fontSize": 10
        }
    ]

Running Linux Commands

  • using bash.exe
bash.exe -c "jupyter-notebook ; /bin/bash"


  • using wsl
wsl jupyter-notebook &

fstab

z: /mnt/z drvfs rw,relatime 0 0

mount network share

mount -t drvfs '\\server\share' /mnt/share

Docker in WSL

  • install docker on linux
  • add to ~/.bashrc
# Start Docker daemon automatically when logging in if not running.
RUNNING=`ps aux | grep dockerd | grep -v grep`
if [ -z "$RUNNING" ]; then
    sudo dockerd > /dev/null 2>&1 &
    disown
fi


Nmap

  • Install Nmap for Windows
  • .bashrc:
alias nmap='"/mnt/c/Program Files (x86)/Nmap/nmap.exe"'

Linux GUI Apps on Windows

sudo apt install xrdp
sudo apt install xfce4 xfce4-goodies

sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
echo xfce4-session > ~/.xsession

/etc/xrdp/startwm.sh:
change to:
  #test -x /etc/X11/Xsession && exec /etc/X11/Xsession
  #exec /bin/sh /etc/X11/Xsession
  startxfce4

sudo /etc/init.d/xrdp start