The recent Windows 10 update, the windows 10’s anniversary update came with a big new feature for developers that will make their life a lot easier, A full Ubuntu-based Bash shell that is able to run Linux software directly on windows. So it basically a subsystem for Linux that Microsoft has added to Windows 10.
Before this was a real pain to get something like this in windows operating system it was requiring a lot of upside down in order to make this possible and a lot of files download like (Cygwin),
However, this isn’t Cygwin or virtual machine or Linux machine compiled for windows this isn’t any of those! instead windows 10 gains a windows subsystem for Linux, which is based on Microsoft’s abandoned Project Astoria work for running Android apps on windows.
The company worked with Canonical to bring you a full Ubuntu-based Bash shell, this allows you to run the Bash shell and the exact binary as the one you would run on Linux.
Despite it being that powerful, there some limitations on the things it can do, for example, it won’t work with server software and graphic software. It for those developers who want to run Linux command-line utilities on windows, these applications get access to the Windows file system, but you can’t use Bash commands to automate normal Windows programs or launch Bash commands from the standard Windows command-line. They get access to the same Windows file system, but that’s it. Not every command-line application will work, either, as this feature is still in beta.
How to Install Bash on Windows 10
1. To get started with the installation and all the things ahead, first, make sure you have windows 10 Anniversary update on your machine and make sure your version of windows is a 64-bit otherwise you won’t enjoy this beautiful feature.
Once you are sure you meet all the requirements to finally go on with the installation, open the Settings app, and click on Update & Security > For Developers. Activate the “Developer Mode” switch here to enable Developer Mode.
2. Next, open the Control Panel, click “Programs,” and click “Turn Windows Features On or Off” under Programs and Features. Enable the “Windows Subsystem for Linux (Beta)” option in the list here and click “OK.”
When you’re done, you’ll be prompted to reboot your computer. Click “Restart Now” to reboot your computer and Windows 10 will install the new feature.
3. After your computer restarts, click the Start button (or press the Windows key), type “bash”, and press “Enter.”
The first time you run the bash.exe file, you’ll be prompted to accept the terms of service. The command will then download the “Bash on Ubuntu on Windows” application from the Windows Store. You’ll be asked to create a user account and password for use in the Bash environment.
if you would like to automatically installation the Bash instead, you can run the following command in a Command Prompt window. This will automatically agree to all prompts and set the default user to “root” with no password just make sure you type the code below in the command prompt exactly the way its there:
lxrun /install /y
How to Use Ubuntu’s Bash Shell and Install Linux Software
If you are reading this part, that means the installation was successful and you are ready to use your Ubuntu Bash shell to do some magic with it :
To open the Bash shell, just open your Start menu and search for “bash” or “Ubuntu.” You’ll see a “Bash on Ubuntu on Windows” application. You can pin this application shortcut to your Start menu, taskbar, or desktop for easier access.
Use the same Linux terminal commands you’d use to get around. If you’re used to the standard Windows Command Prompt with its DOS commands, here are a few basic commands on both Bash and Windows:
· Change Directory: cd in Bash, cd or chdir in DOS
· List Contents of Directory: ls in Bash, dir in DOS
· Move or Rename a File: mv in Bash, move and rename in DOS
· Copy a File: cp in Bash, copy in DOS
· Delete a File: rm in Bash, del or erase in DOS
· Create a Directory: mkdir in Bash, mkdir in DOS
· Use a Text Editor: vi or nano in Bash, edit in DOS
You’ll need to use the apt-get command to install and update the Ubuntu environment’s software. Be sure to prefix these commands with “sudo”, which makes them run as root–the Linux equivalent of Administrator. Here are the apt-get commands you’ll need to know:
· Download Updated Information About Available Packages: sudo apt-get update
· Install an Application Package: sudo apt-get install packagename (Replace “packagename” with the package’s name.)
· Uninstall an Application Package: sudo apt-get remove packagename (Replace “packagename” with the package’s name.)
· Search for Available Packages: sudo apt-cache search word (Replace “word” with a word you want to search package names and descriptions for.)
· Download and Install the Latest Versions of Your Installed Packages: sudo apt-get upgrade
Once you’ve downloaded and installed an application, you can type its name at the prompt and press Enter to run it. Check that particular application’s documentation for more details.
Remember, the software you install in the Bash shell is restricted to the Bash shell. You can’t access it from the Command Prompt, PowerShell, or elsewhere in Windows. The software in the Bash shell also can’t interact directly with or launch Windows programs, although the Bash environment and Windows have access to the same files on your computer.
However, you can create Bash shell scripts (.sh scripts) and run them with the Bash shell.