Access Local Files from Windows Subsystem for Linux (WSL)

Accessing local Windows files from a WSL distribution allows integration between workflows, our local Windows environment and (WSL) Linux environments.

This is done by navigating to the /mnt/c/ directory within your WSL Linux terminal.
Alternatively, you can enter WSL directly from any Windows directory using a terminal. Both approaches provide straightforward ways to integrate your workflows across both platforms.

Additionally, for more advanced workflows, you can create a symbolic link between Windows and WSL directories. Check out my other post, Create a Link Between Local Windows Files and WSL, for a detailed guide.

Navigate in Terminal to /mnt/c/

In a WSL environment, Windows drives are mounted under the /mnt/ directory. For example, the C: drive is accessible at /mnt/c/.

Here’s how you can navigate and interact with local Windows files:

# navigate to home (wsl) linux folder
cd ~

# navigate c:\temp folder on local windows computer
cd /mnt/c/temp
WSL access Windows Files

In the example above, we accessed the C:\temp folder from within the WSL environment. The /mnt/ directory reflects the local Windows drives, allowing you to browse and manipulate files seamlessly.

Open WSL from PowerShell with a Specific Directory

You can also launch WSL directly from a PowerShell terminal while being in any Windows directory.

This method sets the active path in WSL to match the directory you’re working in from Windows. Here’s an example:

# create folder and go to it
mkdir C:\temp\newfolder
cd C:\temp\newfolder

# enter wsl
wsl
PowerShell Terminal Open WSL

Once inside WSL, your default Linux distribution will start, and the working directory will be mounted at the corresponding path, in this case, /mnt/c/temp/newfolder. This is an efficient way to ensure your Linux session begins in a specific Windows directory.


Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Certificates & Encryption (3) Change Data Capture (CDC) (2) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Deleting Data (1) Error Messages (5) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Admin (2) Logging & Monitoring (1) Measuring Databases (10) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (1) SQL Server Agent (5) SQL Server Database Files (1) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (15) SQL Server Network Connectivity (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance (6) SQL Server Permissions (2) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)