The Windows system will also need to be using the 64-bit version of Windows 10 rather than the 32-bit version - see Determining if your version of Windows is a 32-bit or 64-bit version for methods that can be used to determine if the installed version of Windows is a 32-bit or 64-bit version.
If the version of Windows is appropriate, then you can follow the step by step instructions below to install the Linux subsystem.
Type settings in the Cortana "Ask me anything" field at the bottom of the screen and, when you see Settings with a gear icon to the left of it, click on it.
Then select Update & Security, which will be at the bottom of the Settings window.
Next, select For developers.
From the "For developers" window, select Developer mode to "Install any signed app and use advanced development features.
If prompted for administrator credentials, provide the account name and password for an account in the administrators group. You will then see a "Use developer features" window stating that "Turning on developer mode, including installing and running apps from outside the Windows Store, could expose your device and personal data to security risks or harm your device." Click on Yes to proceed to turn on developer mode.
You can then close the Settings window. Next right-click on the Windows Start button at the lower, left-hand corner of the screen and select Control Panel. In the Control Panel window, click on Programs.
Click on "Turn Windows features on or off" under Programs and Features .
Scroll down through the "Turn Windows features on or off" list until you see "Windows Subsystem for Linux (Beta). Put a check in the check box next to that entry by clicking on the entry.
Then click on the OK button. When the changes are completed, you will see a window informing you that "Windows needs to reboot to finish installing the requested changes.
You will need to reboot the system to use Bash on the system. After
rebooting, if you type bash
in the Cortana "Ask me anything"
field, you should see "bash Run Command" as an option you can select
to obtain a Bash command line interface (CLI).
The first time you do so, you will see a window open infoming you "This
will install Ubuntu on Windows, distributed by Canonical and licensed under
its terms available here: https://aka.ms/uowterms"; Type y
in
that window and hit Enter to continue.
Note: as an alternative method of installation of Linux on Windows, at
this point you could open a command prompt window instead and type
lxrun /install /y
which automates the process by answering "y",
i.e., "yes", to all prompts that would appear and sets the default user
to root with no password. Presuming you, instead, proceed with the
installation process that occurs if you hit Enter after selecting
Bash when it appears after the Cortana search, you would then see the following
window:
The software will then be downloaded from the Windows Store.
When the download completes, you will see "Extracting filesystem, this
will take a few minutes..." appear in the bash.exe window. You will next
be prompted to provide a new UNIX username. You can type root
or provide another user name.
-- Beta feature -- This will install Ubuntu on Windows, distributed by Canonical and licensed under its terms available here: https://aka.ms/uowterms Type "y" to continue: y Downloading from the Windows Store... 100% Extracting filesystem, this will take a few minutes... Please create a default UNIX user account. The username does not need to match y our Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username:
Once you've provided the username, you will get a Bash shell prompt.
-- Beta feature -- This will install Ubuntu on Windows, distributed by Canonical and licensed under its terms available here: https://aka.ms/uowterms Type "y" to continue: y Downloading from the Windows Store... 100% Extracting filesystem, this will take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: root Found UNIX user: root Installation successful! The environment will start momentarily... Documentation is available at: https://aka.ms/wsldocs root@VANALLEN:/mnt/c/Windows/System32#
You can enter Unix/Linux commands at this point and see results similar to what you would see on a Unix, Linux, or OS X system at a Bash shell prompt.
root@VANALLEN:/mnt/c/Windows/System32# ps PID TTY TIME CMD 1 ? 00:00:00 init 2 ? 00:00:00 bash 12 ? 00:00:00 ps root@VANALLEN:/mnt/c/Windows/System32#
From this time onwards, if you type bash
in the Cortana
"Ask me anything" field, you shold see "Bash on Ubuntu on Windows"
returned as a "best match" for the Cortana search.
If you type help
at the Bash prompt when you open a Bash
window, you will see a list of commands that you can run.
root@VANALLEN:~# help GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more about the shell in general. Use `man -k' or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled. job_spec [&] history [-c] [-d offset] [n] or hist> (( expression )) if COMMANDS; then COMMANDS; [ elif C> . filename [arguments] jobs [-lnprs] [jobspec ...] or jobs > : kill [-s sigspec | -n signum | -sigs> [ arg... ] let arg [arg ...] [[ expression ]] local [option] name[=value] ... alias [-p] [name[=value] ... ] logout [n] bg [job_spec ...] mapfile [-n count] [-O origin] [-s c> bind [-lpsvPSVX] [-m keymap] [-f file> popd [-n] [+N | -N] break [n] printf [-v var] format [arguments] builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir] caller [expr] pwd [-LP] case WORD in [PATTERN [| PATTERN]...)> read [-ers] [-a array] [-d delim] [-> cd [-L|[-P [-e]] [-@]] [dir] readarray [-n count] [-O origin] [-s> command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] o> compgen [-abcdefgjksuv] [-o option] > return [n] complete [-abcdefgjksuv] [-pr] [-DE] > select NAME [in WORDS ... ;] do COMM> compopt [-o|+o option] [-DE] [name ..> set [-abefhkmnptuvxBCHP] [-o option-> continue [n] shift [n] coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...] declare [-aAfFgilnrtux] [-p] [name[=v> source filename [arguments] dirs [-clpv] [+N] [-N] suspend [-f] disown [-h] [-ar] [jobspec ...] test [expr] echo [-neE] [arg ...] time [-p] pipeline enable [-a] [-dnps] [-f filename] [na> times eval [arg ...] trap [-lp] [[arg] signal_spec ...] exec [-cl] [-a name] [command [argume> true exit [n] type [-afptP] name [name ...] export [-fn] [name[=value] ...] or ex> typeset [-aAfFgilrtux] [-p] name[=va> false ulimit [-SHabcdefilmnpqrstuvxT] [lim> fc [-e ename] [-lnr] [first] [last] o> umask [-p] [-S] [mode] fg [job_spec] unalias [-a] name [name ...] for NAME [in WORDS ... ] ; do COMMAND> unset [-f] [-v] [-n] [name ...] for (( exp1; exp2; exp3 )); do COMMAN> until COMMANDS; do COMMANDS; done function name { COMMANDS ; } or name > variables - Names and meanings of so> getopts optstring name [arg] wait [-n] [id ...] hash [-lr] [-p pathname] [-dt] [name > while COMMANDS; do COMMANDS; done help [-dms] [pattern ...] { COMMANDS ; } root@VANALLEN:~#
You can obtain help information for a particular command by typing
help
followed by the name of the command.
root@VANALLEN:~# help disown disown: disown [-h] [-ar] [jobspec ...] Remove jobs from current shell. Removes each JOBSPEC argument from the table of active jobs. Without any JOBSPECs, the shell uses its notion of the current job. Options: -a remove all jobs if JOBSPEC is not supplied -h mark each JOBSPEC so that SIGHUP is not sent to the job if the shell receives a SIGHUP -r remove only running jobs Exit Status: Returns success unless an invalid option or JOBSPEC is given. root@VANALLEN:~#
Just as on a
Linux,
Unix, or
OS X/macOS
system, you can determine if a command is present using the command which
command
where command is the relevant command in which you
are interested. E.g., you can see that
tcpdump, the venerable command line
packet analyzer is available under the Linux subsystem. The
vi and
GNU nano
text editors are also available to you on Windows now.
root@VANALLEN:~# which tcpdump /usr/sbin/tcpdump root@VANALLEN:~# which vi /usr/bin/vi root@VANALLEN:~# which namo root@VANALLEN:~#
Note: if you are unfamiliar with Linux, unlike the Microsoft Windows
operating system, commands are case-sensitive, e.g., while which
is a command, WHICH
is not.
root@VANALLEN:~# WHICH tcpdump WHICH: command not found root@VANALLEN:~#
Also you need to use forward slashes, i.e., "/", rather than
backslashes, i.e., "\", in directory paths and, if you want to see
files and directories on what is drive "C:" under Windows, you should
look under /mnt/c
.
root@VANALLEN:~# ls / acct boot data etc init lib64 media opt root sbin sys usr bin cache dev home lib lost+found mnt proc run srv tmp var root@VANALLEN:~# ls /mnt/c ls: cannot access /mnt/c/hiberfil.sys: Permission denied ls: cannot access /mnt/c/pagefile.sys: Permission denied ls: cannot access /mnt/c/swapfile.sys: Permission denied Allmyapps inetpub $Recycle.Bin AMD Kaspersky Rescue Disk 10.0 RHDSetup.log BigFishCache MSOCache swapfile.sys BigFishGamesCache pagefile.sys System Volume Information BOOTNXT PerfLogs Users Config.Msi ProgramData Windows csb.log Program Files $Windows.~WS ESD Program Files (x86) hiberfil.sys Recovery root@VANALLEN:~#
The ls command is the command commonly used on Unix and Unix-like operating systems, but, if you prefer you can use the dir command as you would under the Microsoft Windows operating system.
root@VANALLEN:~# dir /mnt/c Allmyapps inetpub $Recycle.Bin AMD Kaspersky\ Rescue\ Disk\ 10.0 RHDSetup.log BigFishCache MSOCache swapfile.sys BigFishGamesCache pagefile.sys System\ Volume\ Information BOOTNXT PerfLogs Users Config.Msi ProgramData Windows csb.log Program\ Files $Windows.~WS ESD Program\ Files\ (x86) hiberfil.sys Recovery root@VANALLEN:~#
Note: you will see spaces in directory names preceded by a backslash. If you want to see the files in a directory and there is a space in the directory name, remember to precede any space in the name with a backslash or, alternatively, put the directory path within double quotes.
root@VANALLEN:~# dir /mnt/c/Program\ Files ATI Realtek Bonjour Reference\ Assemblies CanonBJ Scripts Common\ Files Uninstall\ Information desktop.ini Utiities DIFX Utilities DVD\ Maker WindowsApps GIGABYTE Windows\ Defender Graphics Windows\ Defender\ Advanced\ Threat\ Protection InfraRecorder Windows\ Mail Internet\ Explorer Windows\ Media\ Player iPod Windows\ Multimedia\ Platform iTunes Windows\ NT Microsoft\ Games Windows\ Photo\ Viewer Microsoft\ Office Windows\ Portable\ Devices Microsoft\ Silverlight WindowsPowerShell MSBuild Windows\ Sidebar Network WinRAR root@VANALLEN:~# dir "/mnt/c/Program Files" ATI Realtek Bonjour Reference\ Assemblies CanonBJ Scripts Common\ Files Uninstall\ Information desktop.ini Utiities DIFX Utilities DVD\ Maker WindowsApps GIGABYTE Windows\ Defender Graphics Windows\ Defender\ Advanced\ Threat\ Protection InfraRecorder Windows\ Mail Internet\ Explorer Windows\ Media\ Player iPod Windows\ Multimedia\ Platform iTunes Windows\ NT Microsoft\ Games Windows\ Photo\ Viewer Microsoft\ Office Windows\ Portable\ Devices Microsoft\ Silverlight WindowsPowerShell MSBuild Windows\ Sidebar Network WinRAR root@VANALLEN:~#
If you are familiar with Bash shell scripting, you can create Bash scripts and run them from the Bash shell prompt you now have available to you. If you aren't familiar with Bash scripts, they are similar to Windows batch files.
Note: some Bash commands may not produce the results you expect, e.g., the netstat command issued from a Bash shell prompt in an Ubuntu on Windows window won't show you all of the network ports on which Windows is listening, so issuing that command at the Bash shell prompt won't produce the same results as when you issue it at a Windows command prompt.
root@VANALLEN:~# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path root@VANALLEN:~#
You can close the Ubuntu on Windows Bash shell window by tying
exit
or you can close it as you would any other window under
Windows by clicking on the "X" at the upper, right-hand corner of the window.