Category Archives: Linux

Windows 10 – Start Windows applications from Bash

Working with Bash on Windows, I can say that it significantly simplified the way I can work cross-platform. It has allowed me to use native Linux tools, when working with Linux systems, which is a big step up from using a mix of compiled for Windows Unix tools and GUI applications. Because of this unique functionality Windows 10 has a big lead over any other platform as my day-to-day platform.

For example it is possible to add a new Windows users account directly by using the net.exe tools:

1
net.exe user /add testaccount

Alternatively it is also possible to start Windows PowerShell in Bash to execute a command, for example it becomes possible to use PowerShell to determine which processes are running in the Windows environment and the ps command to determine what is running in Linux:

1
2
powershell.exe -nop -command "Get-Process | Select-Object -First 10"
ps -aux

For me the greatest advantage is the fact that Windows executable files can also be directly called from bash, simplifying the interaction between the different OSes. An example of this is opening explorer in your current working folder in the bash terminal:

1
explorer.exe .

When a path is not accessible for the Windows application, for example anywhere in the Unix file system, a proper error message will be displayed:

1
explorer.exe .

Using this same method it is also possible to add the path to your favorite script editor to the Bash on Windows path allowing them to be directly called from the console. In the following example I will show how to open VSCode directly from Bash:

1
2
3
ls README.md
export PATH=$PATH:/mnt/c/Program\ Files\ \(x86\)/Microsoft\ VS\ Code/
Code.exe README.md

For more information and example of what is possible with the Bash commandline on Windows or I recommend following the Windows Command Line Tools For Developers blog on MSDN.

Path of Linux User-Mode filesystem in Windows 10

Over the past few weeks I have been using the new functionality in the latest Windows 10 insider builds that allows you to run Ubuntu in User Mode on Windows 10. Or as it is also known: Windows Subsystem for Linux. The file system of Ubuntu is located at the following location:

%userprofile%\appdata\local\lxss

To navigate to this location from PowerShell the following code can be used:

1
2
Set-Location -LiteralPath 'C:\Users\Jaap Brasser\appdata\local\lxss\'
Set-Location -LiteralPath "${env:userprofile}\appdata\local\lxss\"

LinuxBashonWindows

By accessing this location it is easy to copy files from the Windows filesystem directly into the Linux file system.

For more information in regards to Linux User-Mode on Windows 10, please refer to the following links:

Links in this Article
Blog – Windows Command Line Tools For Developers
Announcing Windows 10 Insider Preview Build 14316
Video – Running Bash on Ubuntu on Windows!