Microsoft recently launched Bash on Ubuntu on Windows 10 — a shell environment with most of the Linux CLI tools and utilities. Using the same, you can run
awk and many more tools directly in Windows without the need to switch to Linux distro.
You have probably heard of Linux as the free alternative to Windows and OS X. It's one of…Read more
Even if you never tried out Unix or Linux, here’s your chance to learn and experiment with Bash and other *NIX tools in Windows 10. In this introductory tutorial, we’re going to share how to get started with Bash on Windows 10 and use them in various ways.
Bash (Bourne Again SHell) is a text-based shell and a scripting language for Unix and Linux platforms. Bash on Ubuntu on Windows 10 is an optional feature that’s available for people using Windows 10’s Anniversary Update.
It runs on the top of Windows Subsystem for Linux (WSL) and lets you experience Linux right inside your Windows PC.
This new technology enables you to run *NIX commands and compatible command-line tools natively in Windows. You no longer need to install a Unix or Linux distro side by side your Windows OS or setup a virtual machine for trying out *NIX OS.
Compared to a virtual machine, Bash on Ubuntu requires fewer system resources, and lets you access both Windows and Linux tools at the same time.
Bash on Windows 10 is especially useful for developers and system administrators working on open-source projects. This feature comes as an unpredicted gift from Microsoft with support of Canonical.
This is to bridge gap between the proprietary Windows with the free and open source Linux technologies starting with Bash shell.
Bash on Ubuntu on Windows 10 is installable manually if your system runs on Windows 10 having Anniversary Update (build 14393 or later) and supports 64-bit processor. Follow these steps to confirm that your system meets these requirements:
After verifying the requirements, you can install Bash using the following steps:
Note: Bash will install despite the error message shown as in below pic.
Now enable the Windows Subsystem for Linux (an optional feature) using these steps:
Note: It need not be same as your Windows account’s name and password.
Congrats — you’re done installing Bash on Ubuntu on Windows 10 now. You can launch it using the Start menu and enjoy running Unix and Linux utilities now.
After the installation, you can enjoy using Bash with root ("administrator" in Windows term) or full access permissions in Windows 10. The local file system (C: drive) is located in the
/mnt/c directory in this shell environment and same as for your drives.
Note: Same as *NIX systems, Bash on Windows 10’s environment is also case-sensitive, i.e., the names ‘ash’, ‘Ash’, ‘AsH’ and ‘ASH’ are all different.
You can install additional software or update the present tools using the known
apt-get command with the prefix
sudo to run them as root or administrator in Windows.
Below is a list of apt-get commands you can use to install *NIX software:
sudo apt-get update– Update package list information (list of software available to download along with their version numbers)
sudo apt-get install <package-name>– Install a new application package (replace "<package-name>" with the package name to install)
sudo apt-get remove <package-name>– Uninstall a present application package (replace "<package-name>" with the package name to remove)
sudo apt-cache search <query-word>– Search for available packages (replace "<query-word>" with the package name to search)
sudo apt-get upgrade– Download and update the installed software packages
After downloading and installing an application, you can type its name in Bash shell (without any extension) and hit Enter key to run the same.
Do note that Linux-based tools and utilities are restricted to run in the Bash shell only.
In the Bash shell, you can use
vi editors to create shell scripts. After creating the script with required set of commands, save and close the editor, and then follow these steps to run your command-line script:
chmodcommand, for example,
chmod +x ./myscript.shfor a script named "myscript.sh" present in the current directory
./myscript.shfor a script named "myscript.sh" present in the current directory
You don’t need to launch the Bash shell first to execute a *NIX command, rather run a script or launch a program. You can run the command directly using
bash -c, which can be used for various purposes like:
For example, you can do the following steps to launch the vi editor:
bash -c "vi"and click OK to launch the vi editor
Bash on Ubuntu on Windows 10 doesn’t support GUI software natively, but can run some graphics-based tools using the old VNC trick. The trick requires an ‘X Server’ running on your Windows and Bash on Ubuntu configured to route the graphics to that server.
Here’s the step-by-step procedure to achieve the result:
apt-getcommand, for example, run
sudo apt-get install vim-gtkto install the GTK-based Vim editor
export DISPLAY=:0in Bash.
Note:You must run this command every time you reopen Bash
gvimto launch the GTK-based Vim editor
Note: All *NIX-based GUI programs are not yet supported by this trick, so if your favorite program doesn’t work, don’t worry and wait for official support in future updates. Also, you may receive system crashes while running few GUI tools owing to the same reason.
Bash on Ubuntu Windows 10 supports various common commands and avails numerous command-line utilities to help achieve daily tasks and write useful scripts. Here’s a list of common Unix and Linux commands to help you get started with Bash.
Bash on Ubuntu on Windows 10 proves to be a new dawn with Microsoft finally availing support for free and open source software on its Windows platform. This allows developers to leverage the open-source developer ecosystem without side-loading Linux or using a virtual machine.
The system of shell commands is one of the oldest languages for systems communications. Computers have been able…Read more
However, the *NIX apps can’t interact with or launch Windows programs directly, but it’s just a start, so let’s keep our heads up for the great possibilities ahead.
How do you feel about Bash on Ubuntu, and which features you’d like to see for Bash on Ubuntu in future updates of Windows 10? Kindly share your thoughts using comments.
Powered by WPeMatico