Cheat Sheet Library

WSL Cheat Sheet

Run a real Linux distro inside Windows. Run these commands from PowerShell or cmd. Inside the distro, use the Bash and apt sheets.

  • 28 entries
  • 7 sections
  • Updated
  • Click a command to see all its options

28 entries

On this page

Install & Setup #

CommandAction
Install WSL + Ubuntu (admin, then reboot)
Install a specific distro
List distros available online
Update WSL itself
Default distro and version
WSL, kernel and WSLg versions

Managing Distros #

CommandAction
Installed distros, state and WSL version
Start the default distro
Start a specific distro
Start in the Linux home folder
Start as root (useful to reset a forgotten password)
Change the default distro
Convert to WSL 2
New installs use WSL 2
Stop one distro
Stop everything (applies config changes)
Delete a distro and all of its files

Backup & Move #

CommandAction
Back up a distro
Restore / clone to another drive

Files Between Windows and Linux #

FromPath
Windows → Linux files\\wsl$\Ubuntu\home\user or \\wsl.localhost\Ubuntu\...
Linux → Windows C: drive/mnt/c/Users/you
Linux: open the folder in Explorer
Linux: open in VS Code (installs the WSL extension automatically)
Convert paths → /mnt/c/Users (and for the reverse)

Running Programs Across #

CommandAction
Run a Linux command from PowerShell
Run a Windows program from Linux
/ Windows shell commands from Linux
Copy to the Windows clipboard from Linux

Config Files #

/etc/wsl.conf (inside the distro):

[boot]
systemd=true

[user]
default=milan

[interop]
appendWindowsPath=true

%UserProfile%\.wslconfig (Windows, applies to all WSL 2 distros):

[wsl2]
memory=8GB
processors=4
swap=2GB

Run wsl --shutdown afterwards to apply.

Tips #

  • Keep projects inside the Linux filesystem (~/projects), not on /mnt/c. File access is much faster there.
  • Localhost is shared: a dev server on port 3000 in WSL opens at http://localhost:3000 in Windows.
  • GUI Linux apps work out of the box on Windows 11 (WSLg).