Using the Windows Subsystem for Linux (WSL)

Sharing files between Windows Subsystem for Linux and Windows

Start WSL

  • In the Windows start menu select the icon of the Linux operating system you have installed when you set up WSL. The default is Ubuntu.
  • A Linux terminal opens

Access the Windows files from Linux

  • Start WSL
  • In the Linux terminal navigate to the /mnt directory
cd /mnt
  • The drives are mounted to sub-directories
root@P70:/mnt# ls -l
total 0
drwxrwxrwx  c
drwxrwxrwx  d
  • To access the C: Windows drive, navigate to
cd /mnt/c

Access the Linux files from Windows

To start from Windows

  • Open Windows Explorer in Windows 11
  • Navigate to \wsl.localhost\Ubuntu

To start from Linux

  • In the Linux terminal navigate to the directory you want to open in Explorer
  • In the terminal execute the following command. DOnt forget to add the dot to the end to specify the current directory.
explorer.exe .

Managing packages in Linux

To update the Linux packages in Ubuntu and Debian, execute the command

sudo apt update && sudo apt upgrade

Copy paste

If you have ever worked on a Macintosh, (macOS) you had the luxury to have a separate key combination for Copy (Command+C) and cancel (CTRL+C). As Windows does not have a Command key, the Windows terminal helps us with a smart feature:

  • If text is highlighted in the terminal, CTRL+C executes Copy,
  • If no text is highlighted in the terminal, CTLR+C cancels the operation.

Project file location

Place the project files in to the file system you will use during development. Files can be accessed across operating systems, but the access speed can be significantly slower.

Linux projects

For Linux projects place the files under the Linux user directory at

\\wsl$\<DistroName>\home\<UserName>\Project

Windows projects

For windows projects place the project files under the Windows user directory at

C:\Users\<UserName>\Project or /mnt/c/Users/<UserName>/Project$

Useful commands

Get the list of running WSL instances

  • In Windows open a PowerShell terminal and execute
    wsl.exe -l -v
  • You may should see two instances.
    • The star shows the default Ubuntu WSL instance, you open with a WSL terminal without arguments,
    • The second instance was created by Docker Desktop to run Linux containers on the Windows machine.
PS C:\WINDOWS\system32> wsl.exe -l -v
  NAME              STATE           VERSION
* Ubuntu            Running         2
  docker-desktop    Running         2

Leave a comment

Your email address will not be published. Required fields are marked *