Ubuntu Bash on Windows 10: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Mdhasan (talk | contribs)
No edit summary
Mdhasan (talk | contribs)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Intro ===
=== Intro ===


A recent upgrade to early versions of Windows 10 added the ability for the OS to easily run a selection of native Linux software.
A recent upgrade to early versions of Windows 10 build 14316<ref>[https://blogs.windows.com/windowsexperience/2016/04/06/announcing-windows-10-insider-preview-build-14316/] Announcement from Microsoft </ref> added the ability for the OS to easily run a selection of native Linux software.


Test builds of Windows 10 available under the Windows Insider program can run the Bash shell, a command line interpreter that is available in many different Linux distributions, as well as Mac OS X.
Test builds of Windows 10 available under the Windows Insider program can run the Bash shell<ref>[https://msdn.microsoft.com/en-us/commandline/wsl/about] Details about the Bash in Microsoft MSDN</ref>, a command line interpreter<ref>[http://linuxcommand.org/] Official site of linux command organization</ref> that is available in many different Linux distributions, as well as Mac OS X.


The shell includes tools that allow power users to execute complex chains of commands and automate them using scripts.
The shell includes tools that allow power users to execute complex chains of commands and automate them using scripts.


Bash is available via a Universal Windows Platform app. The app runs on the Windows 10 desktop and provides an image of the Linux-based OS Ubuntu that Bash runs on. A selection of native Ubuntu command line software can be installed — such as the version control tool Git and the compiler gcc — and, in general, applications seem perform relatively well.
Bash is available via a Universal Windows Platform app. The app runs on the Windows 10 desktop and provides an image of the Linux-based OS Ubuntu that Bash runs on. A selection of native Ubuntu command line software can be installed — such as the version control tool [https://en.wikipedia.org/wiki/Git_(software) Git] and the compiler gcc — and, in general, applications seem perform relatively well.


To add the Bash app to your Start menu in Windows 10, you'll first need to be signed up to test Windows 10 as part of the Windows Insider program, which you can join by following the steps here.
To add the Bash app to your Start menu in [https://en.wikipedia.org/wiki/Windows_10 Windows 10], you'll first need to be signed up to test Windows 10 as part of the Windows Insider program, which you can join by following the steps here.


Once your Windows 10 Insider build is up and running these are the steps you need to take to add Ubuntu Bash to the Start menu:
Once your Windows 10 Insider build is up and running these are the steps you need to take to add Ubuntu Bash to the Start menu:
Line 82: Line 82:


Once in Bash, if you want to access your Windows files, type 'cd mnt/{your drive letter}' — replacing '{your drive letter}' with the letter of your main Windows drive.
Once in Bash, if you want to access your Windows files, type 'cd mnt/{your drive letter}' — replacing '{your drive letter}' with the letter of your main Windows drive.
==Using the Ubuntu bash==
Those who is experienced using a Bash shell on Linux, Mac OS X, or other platforms, it’ll be right at home. No need to use sudo, as it is already given a root shell. The “root” user on UNIX platforms has  full system access, like the “Administrator” user on Windows. Your Windows file system is located at /mnt/c in the Bash shell environment.
Use the same Linux terminal commands used for linux. Those who just used to the standard Windows Command Prompt<ref>[https://technet.microsoft.com/en-us/library/bb490890.aspx] Windows command line references</ref> 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
It’s important to remember that, unlike Windows, the Bash shell and its Linux-imitating environment are case-sensitive. In other words, “File.txt” with a capital letter is different from “file.txt” without a capital.
==Summary==
Remember, software install in the Bash shell is restricted to the Bash shell.At the moment it is not possible to access it from the Command Prompt, PowerShell, or elsewhere in Windows. 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, it is possible to create Bash shell scripts (.sh scripts) and run them with the Bash shell.
==See also==
[http://linuxcommand.org/learning_the_shell.php Learning the shell]
[http://vim.wikia.com/wiki/Use_Unix_command-line_tools_in_Windows Using vim in windows]
[https://www.npmjs.com/ npm package manager for java script]
[https://www.python.org/shell/ python shell]
==References==
{{reflist|30em}}
[https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/ Official windows blog]

Latest revision as of 03:47, 7 June 2016

Intro

A recent upgrade to early versions of Windows 10 build 14316[1] added the ability for the OS to easily run a selection of native Linux software.

Test builds of Windows 10 available under the Windows Insider program can run the Bash shell[2], a command line interpreter[3] that is available in many different Linux distributions, as well as Mac OS X.

The shell includes tools that allow power users to execute complex chains of commands and automate them using scripts.

Bash is available via a Universal Windows Platform app. The app runs on the Windows 10 desktop and provides an image of the Linux-based OS Ubuntu that Bash runs on. A selection of native Ubuntu command line software can be installed — such as the version control tool Git and the compiler gcc — and, in general, applications seem perform relatively well.

To add the Bash app to your Start menu in Windows 10, you'll first need to be signed up to test Windows 10 as part of the Windows Insider program, which you can join by following the steps here.

Once your Windows 10 Insider build is up and running these are the steps you need to take to add Ubuntu Bash to the Start menu:

Step by step guide

Switch to the Fast Ring

To be able to use Bash on Ubuntu on Windows you'll need to be in the Windows Insider Fast Ring, which will give you access to the latest Windows 10 test builds.

To enable this go to the Start menu, click Settings ->Update & security -> Advanced options (Figure A)'

Near the bottom of the 'Advanced options' window is written 'Choose your Insider level'. Below this text is a blue bar with a slider on it. Pull this slider to the right edge of the bar.

This should select the 'Fast Ring' (Figure B).

After a period, often several hours, Microsoft will switch you to the Fast Ring and Windows Update will begin downloading the latest Windows 10 build, which includes access to Bash on Ubuntu on Windows

Turn on Developer Mode

Once your machine is updated, you'll need to enable Developer Mode. From the Start menu go to Settings -> Update & security. From this page click on the 'For developers' option in the lefthand sidebar (Figure C).

Click the 'Developer mode' radio button and click 'Yes' on the pop-up window titled 'Use developer features' (Figure D).


Now reboot the machine.

Enable 'Windows Subsystem for Linux'

Search for "Windows Features" in the Taskbar and select "Turn Windows features on or off"(Figure E)


Scroll down to the bottom of the 'Windows Features' window and tick the checkbox labelled 'Windows Subsystem for Linux'.



Install Bash on Ubuntu

Click the search box on the Taskbar and type 'cmd'. Open the Command Prompt (Figure G).

Type 'bash' into the command line, hit return, and Windows will begin installing Bash on Ubuntu (Figure H). Accept the terms of service and it will download Ubuntu - which may take some time depending on the speed of your internet connection.

Following the install, you'll be placed into Bash running Ubuntu 14.04 on the Windows Subsystem for Linux (Figure I).

Add Bash on Ubuntu to the Start menu

Close the command prompt and search for 'Ubuntu' in the Taskbar. Right click on the 'Bash on Ubuntu on Windows' icon and click 'Pin to Start' (Figure J).

Click on the Start menu and you can see the Bash on Ubuntu on Windows pinned as a tile and ready to use (Figure K).

Once in Bash, if you want to access your Windows files, type 'cd mnt/{your drive letter}' — replacing '{your drive letter}' with the letter of your main Windows drive.

Using the Ubuntu bash

Those who is experienced using a Bash shell on Linux, Mac OS X, or other platforms, it’ll be right at home. No need to use sudo, as it is already given a root shell. The “root” user on UNIX platforms has full system access, like the “Administrator” user on Windows. Your Windows file system is located at /mnt/c in the Bash shell environment.

Use the same Linux terminal commands used for linux. Those who just used to the standard Windows Command Prompt[4] 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

It’s important to remember that, unlike Windows, the Bash shell and its Linux-imitating environment are case-sensitive. In other words, “File.txt” with a capital letter is different from “file.txt” without a capital.

Summary

Remember, software install in the Bash shell is restricted to the Bash shell.At the moment it is not possible to access it from the Command Prompt, PowerShell, or elsewhere in Windows. 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, it is possible to create Bash shell scripts (.sh scripts) and run them with the Bash shell.

See also

Learning the shell

Using vim in windows

npm package manager for java script

python shell

References

Official windows blog

  1. [1] Announcement from Microsoft
  2. [2] Details about the Bash in Microsoft MSDN
  3. [3] Official site of linux command organization
  4. [4] Windows command line references