Q. How do I enable Bash on Windows 10?
Dept - Windows 10
A. With build 14316 and above you can enable Bash in Windows 10 which provides the Bash shell running on a Ubuntu user-mode image via the new Windows Subsystem for Linux (WSL). This enables Linux tools to be utilized in a Windows environment. Note that you cannot access Windows applications from the Bash shell, essentially the Bash instance is running in an Ubuntu user-mode space so it cannot interact with Windows applications. Note that the Linux Ubuntu is not running in a VM, rather isolated in user-mode space without requiring a Linux kernel and actually running on the Windows kernel via the Windows Subsystem for Linux that intercepts the various system calls (syscall) from the user-mode Ubuntu and translates them accordingly for the Windows kernel.
To enable Bash perform the following:
- Select Start - Settings
- Search for Windows Features and in the results click Turn Windows features on or off
- Enable Windows Subsystem for Linux and click OK
- The installation will require a reboot
- Once the machine has rebooted open a command prompt and type bash to initiate the installation. This will take some time as the Ubuntu image must be downloaded from the Windows Store
- Once installed you will be in the bash environment. The local filesystems are available under /mnt, e.g. /mnt/c/ for c:\
- Type exit to leave bash
A shortcut "Bash on Ubuntu on Windows" will also be added to Start.
Some interesting commands:
- lsb_release -a : View information about the Linux
- ls /proc : Virtual filesystem that displays information about the system
- cat /proc/cpuinfo - View information about the processor
- ls /mnt/c - View C: drive of the Windows OS
- Other commands like vi, gcc, apt-get etc will all work
- Note that tab completion works in the environment