Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on WSL 2

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Installation & Update

Run the following command in an command window with administrator privileges to install WSL 2.

wsl --install

Run the following command to check the version of WSL.

wsl -l -v

Run the following command in a PowerShell to check build information of WSL 2.

(gcm wsl).Version

Run the following command to update WSL 2.

wsl --update

For more details, please refer to Windows Subsystem for Linux Installation Guide for Windows 10 .

General Tips

  1. You can shutdown WSL using the command wsl --shutdown.

GUI for WSL

  1. cmder is a good alternative UI for WSL (and also PowerShell and CMD).

  2. The opensource software Windows Terminal from software is the best terminal emulator for Windows. Please refer to posts My WSL2 and Windows Terminal setup and Getting started with Windows New Terminal + WSL (Windows Subsystem for Linux) on how to set it up for WSL.

Enable SSH into WSL

THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine

Access Linux Filesystems from Windows

https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

With the 1903 update, users can access Linux Filesystem from Windows directly.

General Tips

  1. All windows disks are mounted under /mnt. You can visit all Windows files/directories that do not require admin privilige in WSL. However, if you want to visit files/directories that require admin privilige, you have to run WSL with admin and visit these files/directories using sudo in WSL.

  2. You'd better use files names that work both in Windows and Linux, otherwise, weird behavior might happen.

  3. Shift + Right Click -> "Open CMD here ..."

  4. Starting with Win 10 Creator Update, Ubuntu 16.04 is available. if you installed old Ubuntu bash, you need to first uninstall it and then reinstall again to get Ubuntu 16.04. Upgrade to Ubuntu 16.04 https://www.howtogeek.com/278152/how-to-update-the-windows-bash-shell/

Copy and Paste

Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.

To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the the Options tab, click the checkbox next to QuickEdit Mode.

With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.

Daemon/Service

You cannot run daemon/services in WSL currently. However, it might be supported in future.

Samba Remote File System

cannot mount samba in WSL currently. samba requires kernelspace while WSL only implements a userspace.

References

Comments