WSL: Directories and Files

Continuing from First steps with the Windows Subsystem for Linux

Windows Subsystem for Linux: A Definitive Guide suggests that you add a symbolic link from your Linux home directory to some suitable Windows Directory

I created the windows directory C:\UbuntuHomeLnk on my Windows machine that hosts WSL. From the point of view of Linux on that machine the root of the Windows C drive is /mnt/c/. So in Linux I ran:

ln -s /mnt/c/UbuntuHomeLnk

This has the effect of creating a subdirectory of my Linux home directory called UbuntuHomeLnk. Then I can cd to it and see files created on the Windows side. When I create a file in Linux I can then see it in Windows and vice versa. Of course, this is not strictly necessary. In Linux I could simply

cd /mnt/c/UbuntuHomeLnk

to get to the same place. However, I can see how making that directory look like a subdirectory of my Linux home directory seems prettier.

CD’ing to the actual directory:

gmcdavid@Armagh:~/UbuntuHomeLnk$ cd /mnt/c/UbuntuHomeLnk
gmcdavid@Armagh:/mnt/c/UbuntuHomeLnk$ cd ..
gmcdavid@Armagh:/mnt/c$ ls
ls: cannot access 'DumpStack.log.tmp': Permission denied
ls: cannot access 'hiberfil.sys': Permission denied
ls: cannot access 'pagefile.sys': Permission denied
ls: cannot access 'swapfile.sys': Permission denied
'$Recycle.Bin'  'Documents and Settings'  'Program Files'         ScanState.log                bootmgr
'$SysReset'      DumpStack.log.tmp        'Program Files (x86)'  'System Volume Information'   hiberfil.sys
'$WinREAgent'    MigLog.xml                ProgramData            UbuntuHomeLnk                pagefile.sys
 BOOTNXT         OneDriveTemp              Recovery               Users                        swapfile.sys
 Config.Msi      PerfLogs                  SWSetup                Windows

This is a WSL Linux view of my Windows home directory. WSL does not let me look at Windows system files, hence the “ls: cannot access …: Permission denied” messages. Continuing:

gmcdavid@Armagh:/mnt/c$ cd ..
gmcdavid@Armagh:/mnt$ ls -la
total 8
drwxr-xr-x  4 root     root     4096 Jun 18 20:13 .
drwxr-xr-x 19 root     root     4096 Jul  3 17:28 ..
drwxrwxrwx  1 gmcdavid gmcdavid  512 Jul  3 17:27 c
drwxrwxrwt  2 root     root       40 Jul  3 17:28 wsl
gmcdavid@Armagh:/mnt$

Up one level. This corresponds to “This PC” in Windows files explorer, but the only thing they show common is the c=C: drive. Linux cannot see the DVD player on my machine, or my network drives. It would be nice to see those network drives…. The wsl directory that my Linux terminal sees is empty. I don’t yet know what it is for. I cannot see it from Windows.

1 thought on “WSL: Directories and Files

  1. Pingback: WSL: Files and Environment Variables | From Hilbert Space to Dilbert Space, and beyond

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.