Hello Devz,
You may want to use Linux for many reasons: services, development, scripting, or just for the environment.
And you can use it in a few different ways:
- Install (dual boot) a distro like Ubuntu, Fedora, Mint, …
- Use a virtual machine with VMWare or VirtualBox
- Use “Bash on Ubuntu on Windows” or also called “Windows Subsystem for Linux
This post will explain the power and the many advantages of having this Subsystem for Linux deeply linked and integrated to Windows.
Install Bash for Windows
There are 3 different ways to do it.
1) Press the Windows button and write “windows features”, then select “Turn Windows features on and off”. Check “Windows Subsystem for Linux (beta)” then click OK:
2) Open Powershell as Administrator and run the command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
3) Open the Windows Store and search for Ubuntu (or Suse, …), then click on “Get”:
Now you can start Bash simply by opening CMD then type “bash”.
Basic Linux commands
You can use your new Linux just like any other Linux:
sudo apt update sudo apt upgrade sudo apt install nano sudo apt install python ping www.google.com ifconfig ls pwd grep cat chmod ...
Access and execute Windows file
Just by typing the command “ls” and “pwd”, you will see that you are actually in your Windows Home folder for the current user. But you can go further by typing “notepad.exe”. Which means you can run any Windows application, giving you a lot of opportunities, like running advanced shell script manipulating Windows files and/or applications.
In this example, we will create a text file, then open it with Notepad:
nano test.txt (write "Hello World", then press CTRL-X and save) notepad.exe test.txt
Run Linux commands outside Bash
If you just want to run a Linux command from the Windows Run, simple click the Windows button and type:
bash -c "htop"
For more information about the possibilities of Bash for Windows (how to upgrade the Linux environment, reinstall Bash, change Linux user, …), please read this article.
Enjoy! 🙂