How to install and use Linux Bash in Windows 10

Linux is a free, alternative Operating System to Windows. In recent years, easy- to-use desktop versions such as Ubuntu have become very popular.
Canonical, the people behind Ubuntu, have worked with Microsoft to enable a version of the Unix Shell 'Bash' for Windows 10 .
Why would you wish to do this? In brief, typing commands is a good deal faster than pointing and clicking. There are also thousands of free apps to download and run for which you may have to pay on Windows. This guide will show you how to enable bash and run a few basic, fun commands. 
In order to install Bash on Windows, you need to be running the 64 Bit version of Windows 10 and have installed the Windows 10 Anniversary Update . If you're unsure if you have this, click the search button at the bottom left of your screen and type winver . 
This will display a pop up showing which version of Windows you're running. Check that the "Build" number is at least '1607'. If it isn't, then click the search bar again and search for 'Updates'. Click the option marked 'Check for Updates'.
  • How to download and install the Windows 10 Anniversary Update
The Bash feature in Windows is experimental, so in order to use it, you must enable Developer Mode. Click on the search bar at the bottom left of the screen and typeFor Developers , then click the option labelled 'For Developers Settings'. 
Click the button next to 'Developer mode'. Read the security warning then click 'Yes' to continue. 
The window will show that it's 'Searching for Developer Mode package', then 'Installing Developer Mode Package'.
Finally you'll see a warning message saying that some features might not work until you restart your PC. Restart the machine to make sure it's fully installed.

Once your machine has restarted, click the search bar at the bottom left once again and type the word ‘Programs’. Click on the option marked ‘Programs and Features’. 
A new window will open. Click the link on the left hand side marked ‘Turn Windows Features on or off’. A pop up will appear with a series of features. You need to click the check box next to ‘Windows Subsystem for Linux (Beta)’, then click 'OK'. 
The feature won't activate fully until you restart your machine. Close and backup any important files then click ‘Restart Now’.
Windows will take some time to restart as it applies your new features so give it a few minutes to do this. Once you are back on the desktop, click the search bar at the bottom left and type the word ‘Bash’. Click the option marked ‘Bash – Run Command’.
The Bash window will open announcing it wants to install Ubuntu on Windows. Rest assured this only applies to this window and your other files and programs won't be affected. Type ‘y’ to confirm.
The necessary files will be downloaded from the Windows Store, then extracted automatically. 
Bash will now ask you to choose a username and password. Remember this username and password has no bearing on those you use to log in to Windows and you can choose any combination you like.
Enter the username entirely in lower case e.g ‘john’ not ‘John’. When the system prompts you for the password, you may notice nothing appears as you type. This is a security feature of UNIX to prevent people peering over your shoulder to see your information!
Enter the password slowly then press return. Bash will ask you to repeat the password once more to complete setup.
For your first time with Bash, we're going to install a small, text based program named 'Cowsay'. Type the command:
Now press return. The sudo part of the command invokes administrator privileges, allowing you to make system-wide changes such as installing a new program.
Bash will now ask for your password. Remember the characters won't appear as you type this but Bash is recording them. Press return, then ‘Y’ to confirm you want to install the software. 
Once the text has stopped scrolling, type the command:
to have your words repeated by a text drawn cow. 

Now that you have mastered having a digital cow echo your words back to you, make sure you are comfortable with the process of installing new programs and learn how to stop them.
Run the command
Enter your password once again and then ‘Y’ to confirm. Once the install is complete run the command
to display a nostalgic Matrix-style screen of text. Press Ctrl + C at any time to stop the program. Now that you're familiar with how to install programs, visit this webpage from the Ubuntu website to find more. You can install them with the syntax
As handy as Bash is for command line apps, its primary purposes is to help Developers, which is why you need to enable Developer Features in Windows in order to use it. 
One of the most popular programming languages is Python as it's very simple to set up and use. This should come pre-installed when you downloaded Ubuntu with Bash but run 
to be sure your version is up to date.
A tool for use with Python, 'pip' installs and manages programming packages. Download this with the command:
As you're working in a Terminal, you can't load websites easily but you can retrieve files with the command wget .
Use this to retrieve a simple Python script based on the text adventure game 'Zork':
Run the program with
The game is very basic but you can use commands like ‘Open Mailbox’ and ‘Go East’ to progress. 
Press Ctrl + C to quit and then
to examine the code used in the game. Nano is a very simple text editor in Linux.
See our guide if you'd like to create your own Python adventure game .

The commands we have explored so far barely scratch the surface of Bash's potential as it can do virtually anything Linux can once you have mastered the basics.
For a introduction to some Linux Conventions and basic system commands, check out our handy guide .
The Microsoft Website also has a handy guide to Bash and its companion app lxrunwhich can be used to uninstall and reinstall the Ubuntu image. 
If you want to wipe your Ubuntu installation and start again, click the search bar in Windows and type 'cmd'. 
Click ‘Windows Command Prompt’. Next run the command
Share on Google Plus

0 comments:

Post a Comment