Thanks to the Windows Subsystem for Linux, users of the Microsoft operating system have been able to see something they could hardly imagine in the past become reality. WSL takes advantage of Microsoft’s virtualization to allow users to install and use Linux directly on top of Windows 10. And not only that, but both systems are connected to each other so that, from one, we can access the resources of the other operating system to, for example, open your files.
Disadvantages of using two operating systems at the same time
The main problem with working with two operating systems at the same time, for example with Dual-Boot, is that the files are saved in one or the other. And, if we want to access them from the other operating system, we already have to search for it and copy it to be able to use it. And, when returning to the other operating system, repeat the process.
A simple way to solve it is to have a storage hard disk, shared with both operating systems, so that everything is saved on it and we can access your data at any time. However, if what we use is Windows and Linux thanks to WSL, from now on we will be able to access the data from both systems very easily.
If what we need is to access Linux data from Windows, there are a series of commands for WSL that allow us to mount an EXT4 drive in the explorer to access all the data as if it were just another hard drive. And, if what we need is just the reverse, that is, accessing Windows files from Linux, we will be able to do it. And we will only need one command for it.
Opening Windows files from Linux with WSL
What WSL does is allow us to install a Linux shell. Although Microsoft is working in a graphical mode, and some distros, like Kali, already have their own tool to be able to use it in graphical mode, the original thing, and what gives less problems, is to use WSL as if it were a terminal, a TTY.
If we already have the distro installed and configured on our PC, we simply have to open its console, from a CMD window, and log in until we can have control over it. Once we have reached this point, the next thing we must do is know the complete path, in Windows, to the file we want to open.
Now, the only thing we have to do in our WSL is run the following command. Of course, we must change “path-to-file” for the full path to the file that we have pointed out in the previous point:
cmd.exe /C start "ruta-al-archivo"
When pressing «Enter», the file we have pointed to will be opened automatically. Of course, it will open using the program that we have configured as the default in Windows 10. Now we can edit it, work with it, and when we finish saving the changes.
Open Windows programs from WSL
Another trick that we can take advantage of in WSL is the possibility of opening Windows programs from the Linux bash. This is very useful, especially if we are working with the console in full screen, or with several instances of bash, and we do not want to hold the mouse to open the program in the usual way.
To carry out this task, what we must do is know the path of the executable that we want to open. If it is a common program, such as notepad, we will not have to know the full path, and it will be enough to write the name of the program (notepad.exe) to open it. Otherwise, we will need the full path of the program we want to run in order to open it.
The command that we must execute in this case is practically the same as the previous one, especially changing the destination.
cmd.exe /C start "ruta-al-programa"
cmd.exe /C start "programa.exe"
The main limitation of this method is that we cannot run UWP applications, from the Microsoft Store, from the Windows Subsystem for Linux. Alone, either open files, or run .exe programs. But what we can do is create a shortcut to the UWP program that we have installed on the computer and, using the same command above, open that shortcut.
cmd.exe /C start "ruta-al-acceso-directo"
Thus, we will be able to run the UWP application directly from the Windows Subsystem for Linux. The same can happen if we have a UWP app set as the default to open a certain type of file. If we use the first command to open the file from WSL, then it will open with the UWP app by default.