Menu & Search

Create a Link Between Local Windows Files and WSL

Create a Link Between Local Windows Files and WSL

The ln command in Linux is used to create a link between files. This is useful for sharing files between your local machine and WSL.

I’m linking to a ‘projects’ folder in this post but I get an error when cloning git repos in them (chmod error). Using mounted Windows drives for version-controlled projects is appearing to be a no-go.

# Create a New Linked Folder
# Remove a Linked Folder

Create a New Linked Folder

# Create sym link wsl
ln -s /mnt/c/projects

-s Create symbolic links instead of hard links.

First I’m creating a local folder and then creating a link to the folder in my WSL home directory.

PowerShell New-Item

Next, I’m creating a new folder and file within WSL on the linked folder.

Create Folder and File Linux

And here’s the file created above shown within the local Windows environment.

Folder and File in Windows Explorer

Remove a Linked Folder

List the files (-lai) to check for existing links ad then remove as your would a file (rm command).

Remove Symlink

We’re deleting the object visible to Linux here, not the folder in Windows.

3 Comments

  1. […] creating a new SSH key within a linked folder, which means my SSH keys are backed up on the local machine in-case anything happens on this WSL […]

  2. […] encountered this error message when attempting to clone a git repo on a linked folder within […]

  3. Walber
    2 years ago

    I am a Brazilian programmer. For me the above method worked perfectly on Windows 11 with Ubuntu 22.04. Thanks!