Microsoft Windows may be the dominant player on the desktop, but the rapidly increasing open source software market—especially for admin and dev tools—clearly favors Linux. Not to mention the mobile market, where Android uses Linux variants. If you’re a developer on Windows, the drumbeat to get hip to Linux capabilities keeps getting louder.
Over the years, Microsoft has introduced various workarounds for using Linux capabilities on Windows, such as PowerShell with SSH and Cygwin and MSYS. Running Linux inside a virtual machine is another option. But VMs consume a significant amount of resources and don’t provide a first-class Linux experience, as you can’t edit local files or get full access to local drives, for example.
As the IT world is turning toward Linux for many projects, Microsoft has come up with a new offering to tap into this growing market. Bash on Windows is the answer. Here we guide you through installing Bash on Windows and give you a taste of what you can do—and why you would do it—in the Linux command line.
An overview of Bash on Windows
Bash on Windows is a new feature added to Windows 10. Microsoft has teamed up with Canonical, aka the creators of Ubuntu Linux, to build this new infrastructure within Windows called the Windows Subsystem for Linux (WSL). It allows developers to access a complete set of Ubuntu CLI and utilities. With a native Linux experience, developers can run Linux commands on Windows, including access to local files and drives. As Linux is natively integrated into Windows, developers get the flexibility to work on the same file in Linux and Windows. Simply put, Bash on Windows brings Ubuntu userland to Windows minus the Linux kernel.
Bash vs. PowerShell
Microsoft already has a command shell in PowerShell. So how does Bash on Windows differ? PowerShell is Microsoft’s configuration management framework for automating tasks. It’s used to manage Windows with its API-oriented architecture. Bash, on the other hand, mostly relies on text files for automation and development. The two differ in both focus and design. For example, when you list files in a directory using the
ls command, PowerShell displays the output as file objects, whereas Bash on Windows displays the output as a set of strings. Thankfully, for Windows admins, you can work with both solutions side by side and get the best of both worlds.
One word of caution: PowerShell has aliases that allow you to think you’re running traditional Bash commands when, in fact, you’re running PowerShell cmdlets. This may trip up some people. For instance,
ls is an alias for the
Get-ChildItem command. Similarly,
pwd is an alias for
cd is an alias for
Set-Location. For a list of all aliases in PowerShell, use the
Sign up for MIS Asia eNewsletters.