Archive for January 2021

Installing Linux bash shell on Windows

Cananonical and Windows have linked up to provide the ability to run Linux on Windows. Developers can also use Cygwin, MSYS, or run Linux in a virtual machine, but these workarounds have their own disadvantages and can overload systems. Bash on Windows provides a Windows subsystem and Ubuntu Linux runs on top of it.

Basically, Windows allows you to run the same Bash shell that you find on Linux. This way you can run Linux commands inside Windows without the needing to install a virtual machine, or dual booting Linux/Windows. You install Linux inside Windows like a regular application. This is a good option if you want to learn Linux/Unix commands.

How to enable

  • Go to Control Panel – Programs and Features – Turn Windows Features on and off.
  • Enable Windows Subsystem for Linux and Virtual Machine Platform
  • Reboot
  • Go to the Windows store and search for Linux or Ubuntu. Install the distribution you want. In my case Ubuntu.
  • Once Ubuntu has installed, you will need to set up a username and password
  • This occurs for the first run. Bash shell will be available to use the next time you log in.
  • When you open the Bash shell in Windows, you are literally running Ubuntu. Developers can now run Bash scripts, Linux command-line tools like sed, awk, grep, and Linux-first tools like Ruby, Git, Python, etc. directly on Windows.
  • Search for bash or wsl in the Windows search box
  •  Almost all Linux commands can be used in the Bash shell on Windows
  • Opening bash and wsl will display as a “Run command” that can be selected to instantly open the bash shell. The difference with using either of these methods is that they open in the /mnt/c/Windows/System32 directory so you can browse the System32 subdirectory in Windows 10.
  • Or you can simply open the Ubuntu app

Examples

  • You can run sudo apt-get update and sudo apt-get upgrade to obtain and install updates along with all usual Linux commands.