create account

Getting Started with Bash on Windows by tomshwom

View this thread on: hive.blogpeakd.comecency.com
· @tomshwom ·
$1.79
Getting Started with Bash on Windows
<center>[![](https://steemitimages.com/DQmQFc8Z7rKHjg2yaxMzNt15ZvBesjUzJZ4gCsXUJtaFdto/image.png)](http://www.omgubuntu.co.uk/wp-content/uploads/2016/08/bash.jpg)</center>


# Preface
---

This isn't a super new feature of Windows 10, but **I'm planning on doing some Python-related content in the near future** and I figured I'd show you all how I actually do my development work.

There's other great guides out there on how to install this, so I'll not be taking a super detailed look at that.  Instead, I'll be linking to different useful resources you can use to get up and running, and I'll even throw in some tips that will really help make things easy.

**You will want to have some basic experience with the Bash shell and the Linux filesystem**, but you certainly don't have to be a pro.  You will probably want to know some basic Python programming too if you want to follow along in my future posts that I'll be doing using Bash on Ubuntu on Windows.

# What is the Windows Subsystem for Linux?
---

The **[Windows Subsystem for Linux (WSL)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)** is a compatibility layer that allows Linux binary executables run natively in Windows 10.  Originally, this feature was released during the Anniversary Update, and only an Ubuntu image was available.  The Fall Creators Update added Fedora and Suse images, and made it simple to install the distributions through the Windows Store. Users can use the WSL to run a Linux userland containing things like a Bash shell, Linux command-line tools like ```grep```, ```sed``` and ```awk```, and interpreters for programming languages like Python and Ruby.<sub>[1](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)</sub>

You can learn more in the official MSDN documentation **[here](https://msdn.microsoft.com/en-us/commandline/wsl/about)**.

# Installing Bash on Ubuntu on Windows
---

Out of the available images, I prefer using Ubuntu simply because it's very familiar and easy.  The only other distros I'm very familiar with are **[Tails](https://tails.boum.org/)** and **[Backtrack 5](https://www.backtrack-linux.org/)** (which is now [Kali](https://www.kali.org)), and neither are suited for the development we want to be doing.

## Check for compatibility

You need to be running a 64-bit version of Windows 10 that is at least the 1607 build or later.

Go to **Settings** > **System** > **About** to check the OS Build and System type fields.

<center>![](https://steemitimages.com/DQmbNXVKstcU83bstgYkELBxK8JE6ppyzJwd5Mh47qBKzre/image.png)</center>

## Install the Windows Subsystem for Linux

The best directions can be found **[here](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)**.

Remember that your UNIX username and password are unique to the subsystem and are **not related to your Windows credentials**.  The first user account you create is automatically configured to be the default user and to have **administrative privileges** (member of the sudo group).

# Tips & Tricks
---

## Adding "Open Bash Here" to the context menu

One of the nice little features in Ubuntu is the ability to right-click in any folder and open up a terminal right in that directory.  Thankfully, with a bit of registry tweaks, you can do it in Windows too!  **Remember to back up your registry before making any edits** - you can permanently damage your system if you mess up your registry.

<center>![](https://steemitimages.com/DQmdMajYewC6kGwYPSFiGYdo8fhKsfyA8pdiGLjEKbQuTft/image.png)</center>

I'm following the guide found **[here](https://www.howtogeek.com/270810/how-to-quickly-launch-a-bash-shell-from-windows-10s-file-explorer/)** by How-To Geek.

* Start by opening the registry editor by pressing the **Windows key + R** and typing **regedit**.

* Navigate through the folder tree to ```\HKEY_CLASSES_ROOT\Directory\Background\shell```, right click the ```shell``` folder and select **New** > **Key**. Name the key something recognizable like "bash".

* Select the new key and double-click ```(Default)``` in the right pane.  This is where you will enter the text that will be displayed in the context menu, I chose "Open Bash here".

<center>![](https://steemitimages.com/DQmS1eQX41B5ahRUgqSyytBrM3yhBHP2fJJvQ9qEN9UrCoW/image.png)</center>

* (Optional) If you want the Bash icon to show up, right click the ```bash``` entry (or whatever you named it), and choose **New** > **String Value**.  Name the value ```Icon```, double-click it, and enter ```%USERPROFILE%\AppData\Local\lxss\bash.ico```.

* Next, create a new key named ```command``` by right-clicking the **bash** > **New >** > **Key**. Select the new command key and double click ```(Default)``` in the right pane.  Set the value to ```C:\Windows\System32\bash.exe```.

## Navigating the Windows file system in Bash

* Once you have your Bash shell open, you can navigate to **```mnt/c/Users/username/Desktop```** to get to the desktop of a Windows user account.  Your drive letter may be different from "c", and you'll have to put in your own username instead of "username".

## Copy & pasting to and from Bash

* Copy from the shell: highlight text and hit **enter**
* Paste into the shell: **right-click** in the terminal

## Updating

* **```apt-get```** - launches to Linux Package Manager
* **```sudo apt-get update```** - refreshes package availability
* **```sudo apt-get upgrade```** - upgrades current packages
* **```sudo apt-get clean```** - cleans the apt cache

## More tips & tricks

* A ~45 minute video: **["30 Tips and Tricks for Managing and Running Ubuntu/Bash/Windows Subsystem for Linux"](https://channel9.msdn.com/Events/Ignite/Australia-2017/WIN321b)**.  It gets into a lot of things, but there's a ton of useful information in here for creating virtual desktops, using Linux tools, and much more.

---

<center><sub>Leave a **like** or **resteem** if you found this helpful. You can also support me by sending ETH or ERC20 toeksn to **Tomshwom.eth**. Leave your thoughts below about what you think and on which content you'd like to see in the future!</sub></center>
👍  , , , , , , , , , , , , , , , , , , ,
properties (23)
authortomshwom
permlinkgetting-started-with-bash-on-windows
categorytechnology
json_metadata{"tags":["technology","programming","linux","windows","bash"],"image":["https://steemitimages.com/DQmQFc8Z7rKHjg2yaxMzNt15ZvBesjUzJZ4gCsXUJtaFdto/image.png","https://steemitimages.com/DQmbNXVKstcU83bstgYkELBxK8JE6ppyzJwd5Mh47qBKzre/image.png","https://steemitimages.com/DQmdMajYewC6kGwYPSFiGYdo8fhKsfyA8pdiGLjEKbQuTft/image.png","https://steemitimages.com/DQmS1eQX41B5ahRUgqSyytBrM3yhBHP2fJJvQ9qEN9UrCoW/image.png"],"links":["http://www.omgubuntu.co.uk/wp-content/uploads/2016/08/bash.jpg","https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux","https://msdn.microsoft.com/en-us/commandline/wsl/about","https://tails.boum.org/","https://www.backtrack-linux.org/","https://www.kali.org","https://msdn.microsoft.com/en-us/commandline/wsl/install_guide","https://www.howtogeek.com/270810/how-to-quickly-launch-a-bash-shell-from-windows-10s-file-explorer/","https://channel9.msdn.com/Events/Ignite/Australia-2017/WIN321b"],"app":"steemit/0.1","format":"markdown"}
created2017-10-17 16:51:39
last_update2017-10-17 16:51:39
depth0
children2
last_payout2017-10-24 16:51:39
cashout_time1969-12-31 23:59:59
total_payout_value1.406 HBD
curator_payout_value0.388 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,096
author_reputation1,713,446,395,686
root_title"Getting Started with Bash on Windows"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id17,907,366
net_rshares793,301,826,975
author_curate_reward""
vote details (20)
@amanpathak · (edited)
Why you flagged this comment 


https://steemit.com/bitcoin/@boxmining/komodo-in-a-nutshell-writeup#@techhelp/re-boxmining-20171017t142949970z

Calling @steemcleaners
👎  
properties (23)
authoramanpathak
permlinkre-tomshwom-getting-started-with-bash-on-windows-20171018t035929716z
categorytechnology
json_metadata{"tags":["technology"],"users":["steemcleaners"],"links":["https://steemit.com/bitcoin/@boxmining/komodo-in-a-nutshell-writeup#@techhelp/re-boxmining-20171017t142949970z"],"app":"steemit/0.1"}
created2017-10-18 04:00:09
last_update2017-10-18 04:01:06
depth1
children1
last_payout2017-10-25 04:00:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length166
author_reputation1,947,376,043,366
root_title"Getting Started with Bash on Windows"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id17,945,361
net_rshares-11,928,135,164
author_curate_reward""
vote details (1)
@tomshwom ·
$0.03
Because it's a shit comment, has no substance, and is blatantly advertising the @techhelp content even though it's irrelevant to anything on the post.
👍  
properties (23)
authortomshwom
permlinkre-amanpathak-re-tomshwom-getting-started-with-bash-on-windows-20171018t135742306z
categorytechnology
json_metadata{"tags":["technology"],"users":["techhelp"],"app":"steemit/0.1"}
created2017-10-18 13:57:42
last_update2017-10-18 13:57:42
depth2
children0
last_payout2017-10-25 13:57:42
cashout_time1969-12-31 23:59:59
total_payout_value0.025 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length150
author_reputation1,713,446,395,686
root_title"Getting Started with Bash on Windows"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id17,981,778
net_rshares11,749,213,137
author_curate_reward""
vote details (1)