Running bash commands from a Windows 10 command prompt

Bash Ubuntu style is now included with Windows 10.

It is always in your path %PATH%, you can confirm this by typing:

where bash
C:\Windows\System32\bash.exe

So you do not have to prefix the directory to the command.  The bash command environment can be started by simply typing:

bash
 thedude@OctoBeast:/mnt/f/python-tests$

Notice the bash prompt is showing user@host:/mount/drive-letter/sub-directory in a format different than Windows does.  This format is how the bash environment “sees” your Windows environment.

You can also issue bash commands directly from the Windows 10 command prompt via:

F:\python-tests>bash -c 
pwd /mnt/f/python-tests 

F:\python-tests>bash -c "ls -al" 
total 298 
drwxrwxrwx 0 root root 512 May 11 08:13 . 
drwxrwxrwx 0 root root 512 May 11 07:29 .. 
-rwxrwxrwx 1 root root 692 May 11 08:13 bastion-close.py 
-rwxrwxrwx 1 root root 307 May 11 08:13 cleanup-stuff.py

Note that bash commands with switches and or parameters (in other words with a space in them) should be enclosed in double quotes.

More from LonzoDB on AWS

Leave a Reply

Your email address will not be published. Required fields are marked *