1. Home
  2. Windows Tips
  3. Open files from windows subsystem for linux on windows 10

How to open files from Windows Subsystem for Linux on Windows 10

Windows subsystem for Linux gives Windows 10 users a Linux shell on Windows machine making it infinitely easier to use Linux without having to switch to a different system. In some cases, users might just be able to forgo having a separate Linux system altogether and get things done with just a Windows system. If you’re still learning to use WSL, you might be wondering how you can open files from Windows Subsystem for Linux. You can do so with a simple command.

Open files from WSL

In order to open files from WSL, you need to know the command and you need to know the complete path to the file you want to open. The path can be copied from File Explorer.

Once you have the path to the file you want to open, open Bash. You can use Windows search to open it, however, if it doesn’t appear in the search results, you likely have not enabled WSL on your system or you have not installed Linux on it after enabling it. Go ahead and enable WSL and install Ubuntu from the Microsoft Store.

Run the following command. Replace ‘complete-path-to-file’ with the complete path to the file you want to open.

Command

cmd.exe /C start "complete-path-to-file"

Example

cmd.exe /C start "D:\1A.png"

The file will, of course, open using an app that’s installed on your Windows 10 PC. In fact, it will open in the default app that’s set for that particular file type.

You can use this same command to open an app on Windows 10. All you need to do is enter the path to the EXE or a shortcut of the app.

cmd.exe /C start notepad.exe

With Notepad, you don’t need the complete path but with other third-party apps that you’ve installed, and quite a few stock ones as well, you will need the complete path. This won’t work for UWP apps however it will work for files that open in UWP apps. For example, if you still have the old Edge app on your Windows 10 PC and you’ve set it as the default PDF viewer, you will be able to use the command given above to open a PDF file in Edge however, you will not be able to use above command to open Edge since UWPs do not have an EXE.

There is a simple workaround to this though; an app shortcut. Create an app shortcut to the UWP app that you want to be able to open from WSL, get the complete path to the shortcut, and use it with the command given above. It will open the UWP.

2 Comments

  1. I ended up using ‘wslview’ instead. Check it out at https://github.com/wslutilities/wslu

  2. Windows doesn’t know how to find my home directory:

    $ cmd.exe /C start graph.png
    ‘\\wsl$\Ubuntu\home\atsaloli’
    CMD.EXE was started with the above path as the current directory.
    UNC paths are not supported. Defaulting to Windows directory.
    The system cannot find the file graph.png.
    $

    I’d like to be able to open files in my home directory.