Skip to content
Commitpedia
Log in Join & edit

Work across Windows and WSL: files, paths and running tools from both sides

WSL is most useful when Windows and Linux cooperate: open Linux folders in Explorer, run Windows programs from bash, convert paths with wslpath, use Docker and VS Code, and avoid the slow cross-file-system trap.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of Work across Windows and WSL: files, paths and running tools from both sides: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
3 min

After installing WSL you have two operating systems on one keyboard. This entry collects the practical habits that make them feel like one machine: where to keep files, how to call across the boundary, and the handful of settings worth changing.

Two file systems, one rule

Linux sees Windows drives under /mnt/c; Windows sees Linux under \\wsl.localhost\<Distro>. Both directions work, but crossing the boundary is slow for anything that touches many small files. The rule: keep files on the side whose tools you run on them. A Node or Python project you build in Ubuntu belongs in /home/ana/projects, not in /mnt/c/Users/ana/projects. Documents you open in Word stay on C:.

cd /mnt/c/Users/ana/Downloads       # Windows files from Linux
cp /mnt/c/Users/ana/Downloads/data.csv ~/projects/
explorer.exe .                      # open the current Linux folder in Explorer

In Explorer, the Linux entry in the sidebar lists every distribution. You can drag and drop files there like any other folder. Avoid editing files under the hidden Linux installation folder in %LocalAppData% directly; always go through the \\wsl.localhost path.

Run Windows programs from Linux

Any Windows executable on your Windows PATH can be called from bash by adding .exe. Output comes back as text you can pipe:

notepad.exe ~/notes.txt
code .                               # VS Code with the WSL extension
powershell.exe -NoProfile -Command "Get-Date"
ipconfig.exe | grep -i 'ipv4'
clip.exe < output.txt                # copy to the Windows clipboard
cmd.exe /c dir                       # cmd commands

Windows programs receive Windows paths, not Linux ones. notepad.exe ~/notes.txt works because WSL translates the argument for you, but when you build a path in a string, convert it with wslpath:

wslpath 'C:\Users\ana\Documents'        # -> /mnt/c/Users/ana/Documents
wslpath -w ~/projects/site               # -> \\wsl.localhost\Ubuntu\home\ana\projects\site

Run Linux commands from Windows

wsl ls -la ~
wsl -d Ubuntu -- grep -c error /var/log/syslog
wsl --cd C:\Projects\site -- npm run build
Get-Content .\names.txt | wsl sort | wsl uniq -c

wsl <command> runs the command in the default distribution and returns its output to PowerShell, so Linux tools can sit in the middle of a PowerShell pipeline. --cd sets the starting folder; -- marks where wsl’s own options end.

Networking between the two

  • A server listening in WSL (for example npm run dev on port 5173) is reachable from a Windows browser at http://localhost:5173. WSL forwards localhost automatically.
  • The other direction is not automatic in the default NAT mode: to reach a Windows service from Linux, use the Windows host’s address, which is the nameserver line in /etc/resolv.conf, or switch to mirrored networking where localhost is shared.
  • Other machines on your network cannot see WSL ports unless you forward them with netsh interface portproxy or use mirrored mode.

Docker and systemd

Docker Desktop for Windows integrates with WSL: enable your distribution under Settings, Resources, WSL integration and the docker command appears in Ubuntu. Alternatively install Docker Engine inside Ubuntu the normal Linux way; that needs systemd, which modern WSL enables by default. Check and, if needed, turn it on:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
cat /etc/wsl.conf
sudo tee -a /etc/wsl.conf > /dev/null <<'EOF'
[boot]
systemd=true
EOF

Then wsl --shutdown from PowerShell and start again. systemctl status should now work. Careful: enabling systemd changes how services start inside the distribution; to undo, set systemd=false or remove the [boot] section and shut WSL down again.

Settings worth knowing

Per-distribution options live in /etc/wsl.conf inside Linux; global VM options live in %UserProfile%\.wslconfig on Windows. Both take effect after wsl --shutdown.

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

Limiting memory stops WSL from slowly taking most of the machine’s RAM for its file cache. Inside Linux, [interop] in wsl.conf can turn off Windows PATH inheritance (appendWindowsPath = false) if Windows tools shadow Linux ones of the same name.

Backups

wsl --export Ubuntu D:\wsl-backups\ubuntu-2026-10.tar
wsl --import Ubuntu-restore D:\wsl\ubuntu-restore D:\wsl-backups\ubuntu-2026-10.tar

--export writes the whole distribution to a tar file; --import creates a new distribution from it at the folder you choose. It is also the way to move WSL to another drive.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0049 Pipes and redirection: connecting commands A pipe sends one command's output into another command, and redirection sends output to a file. Together they let small tools build… Beginner · Explains an idea · Linux, macOS Article Basics · Text processing 15 Oct 2026
  • 0050 File permissions: chmod, chown and what 755 means Every file has an owner, a group and read/write/execute permissions for three kinds of users. chmod changes the permissions and chown changes… Beginner · Explains an idea · Linux, macOS Article Basics 15 Oct 2026
  • 0051 Environment variables and PATH Environment variables are named settings that every program inherits from the shell. PATH is the one that tells the shell where to… Beginner · Explains an idea · Linux, macOS Article Basics 15 Oct 2026
  • 0057 Shell cheat sheet: everyday commands A quick reference for moving around, managing files, viewing and searching text, checking processes and disk space in bash and zsh, with… Beginner · Cheat sheet · Linux, macOS Article Basics · Command-line tools 15 Oct 2026
  • 0284 What is a shell? A shell is the program that reads the commands you type and tells the operating system to run them. Beginner · Explains an idea · Any system Article Basics 15 Oct 2026
  • 0285 What is a terminal? A terminal is the window where you type commands; the shell inside it does the actual work. Beginner · Explains an idea · Any system Article Basics 15 Oct 2026

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +4,690 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?