Windows Subsystem for Linux. Accessing files.

By | July 7, 2024

Linux distributions uses the Filesystem Hierarchy Standard (FHS) which defines the universal directory structure (like home, usr, bin, tmp and so on) and directory contents. To access to Windows c: drive from install WSL Linux distribution use /mnt/c directory. Let us create c:\Temp\ubuntu.txt file from WSL ubuntu 24.04 distribution:

C:\>wsl -d Ubuntu-24.04
smoke29@MSI:/mnt/c$ sudo echo “From wsl Ubuntu”>/mnt/c/Temp/ubuntu.txt
[sudo] password for smoke29:
sudo: a password is required
smoke29@MSI:/mnt/c$ echo “From wsl Ubuntu”>/mnt/c/Temp/ubuntu.txt
smoke29@MSI:/mnt/c$ ls -l /mnt/c/Temp/
total 0
-rwxrwxrwx 1 smoke29 smoke29 16 Jul 7 10:04 ubuntu.txt
smoke29@MSI:/mnt/c$ cat /mnt/c/Temp/ubuntu.txt
From wsl Ubuntu

Now about access to c:\Temp\ubuntu.txt file from Windows command prompt (cmd.exe). By the way it is possible to start cmd.exe and other Windows applications directly from WSL Linux distribution terminal:

smoke29@MSI:/mnt/c$ cmd.exe
Microsoft Windows [Version 10.0.22621.1848]
(c) Microsoft Corporation. All rights reserved.

C:\>type c:\Temp\ubuntu.txt
From wsl Ubuntu


From Windows side the simplest way to access to WSL Linux files is via File Explorer:
WSL Ubunty FHS

Related post: Windows Subsystem for Linux. Installation Linux Distributions.

Leave a Reply

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