Scott Hanselman

Setting up a Shiny Development Environment within Linux on Windows 10

April 14, 2017 Comment on this post [43] Posted in Linux | Win10
Sponsored By

While I was getting Ruby on Rails to work nicely under Ubuntu on Windows 10 I took the opportunity to set up my *nix bash environment, which was largely using defaults. Yes, I know I can use zsh or fish or other shells. Yes, I know I can use emacs and screen, but I am using Vim and tmux. Fight me. Anyway, once my post was done, I starting messing around with open source .NET Core on Linux (it runs on Windows, Mac, and Linux, but here I'm running on Linux on Windows. #Inception) and tweeted a pic of my desktop.

By the way, I feel totally vindicated by all the interest in "text mode" given my 2004 blog post "Windows is completely missing the TextMode boat." ;)'

Also, for those of you who are DEEPLY NOT INTERESTED in the command line, that's cool. You can stop reading now. Totally OK. I also use Visual Studio AND Visual Studio Code. Sometimes I click and mouse and sometimes I tap and type. There is room for us all.

WHAT IS ALL THIS LINUX ON WINDOWS STUFF? Here's a FAQ on the Bash/Windows Subsystem for Linux/Ubuntu on Windows/Snowball in Hell and some detailed Release Notes. Yes, it's real, and it's spectacular. Can't read that much text? Here's a video I did on Ubuntu on Windows 10.

A number of people asked me how they could set up their WSL (Windows Subsystem for Linux) installs to be something like this, so here's what I did. Note that will I've been using *nix on and off for 20+ years, I am by no means an expert. I am, and have been, Permanently Intermediate in my skills. I do not dream in RegEx, and I am offended that others can bust out an awk script without googling.


So there's a few things going on in this screenshot.

  • Running .NET Core on Linux (on Windows 10)
  • Cool VIM theme with >256 colors
  • Norton Midnight Commander in the corner (thanks Miguel)
  • Desqview-esque tmux splitter (with mouse support)
  • Some hotkey remapping, git prompt, completion
  • Ubuntu Mono font
  • Nice directory colors (DIRCOLORS/LS_COLORS)

Let's break them down one at a time. And, again, your mileage may vary, no warranty express or implied, any of this may destroy your world, you read this on a blog. Linux is infinitely configurable and the only constant is that my configuration rocks and yours sucks. Until I see something in yours that I can steal.

Running .NET Core on Linux (on Windows 10)

Since Linux on Windows 10 is (today) Ubuntu, you can install .NET Core within it just like any Linux. Here's the Ubuntu instructions for .NET Core's SDK. You may have Ubuntu 14.04 or 16.04 (you can upgrade your Linux on Windows if you like). Make sure you know what you're running by doing a:

~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
~ $

If you're not on 16.04 you can easily remove and reinstall the whole subsystem with these commands at cmd.exe (note the /full is serious and torches the Linux filesystem):

> lxrun /uninstall /full
> lxrun /install

Or if you want you can run this within bash (will take longer but maintain settings).

NOTE that you'll need Windows 10 Creators Edition build 16163 or greater to run Ubuntu 16.04. Type "winver" to check your build.

sudo do-release-upgrade

Know what Ubuntu your Windows 10 has when you install .NET Core within it. The other thing to remember is that now you have two .NET Cores, one Windows and one Ubuntu, on the same (kinda) machine. Since the file systems are separated it's not a big deal. I do my development work within Ubuntu on /mnt/d/github (which is a Windows drive). It's OK for the Linux subsystem to edit files in Linux or Windows, but don't "reach into" the Linux file system from Windows.

Cool Vim theme with >256 colors

That Vim theme is gruvbox and I installed it like this. Thanks to Rich Turner for turning me on to this theme.

$ cd ~/
$ mkdir .vim
$ cd .vim
$ mkdir colors
$ cd colors
$ curl -O
$ cd ~/
$ vim .vimrc

Paste the following (hit ā€˜iā€™ for insert and then right click/paste)

set number
syntax enable
set background=dark
colorscheme gruvbox
set mouse=a

if &term =~ '256color'
" disable Background Color Erase (BCE) so that color schemes
" render properly when inside 256-color tmux and GNU screen.
" see also
set t_ut=

Then save and exit with Esc, :wq (write and quit). There's a ton of themes out there, so try some for yourself!

Norton Midnight Commander in the corner (thanks Miguel)

Midnight Commander is a wonderful Norton Commander clone that Miguel de Icaza started, that's licensed as part of GNU. I installed it via apt, as I would any Ubuntu software.

$ sudo apt-get install mc

There's mouse support within the Windows conhost (console host) that bash runs within, so you'll even get mouse support within Midnight Commander!

Midnight Commander

Great stuff.

Desqview-esque tmux splitter (with mouse support)

Tmux is a terminal multiplexer. It's a text-mode windowing environment within which you can run multiple programs. Even better, you can "detach" from a running session and reattached from elsewhere. Because of this, folks love using tmux on servers where they can ssh in, set up an environment, detach, and reattach from elsewhere.

NOTE: The Windows Subsystem for Linux shuts down all background processes when the last console exits. So you can detach and attach tmux sessions happily, but just make sure you don't close every console on your machine.

Here's a nice animated gif of me moving the splitter on tmux on Windows. YES I KNOW YOU CAN USE THE KEYBOARD BUT THIS GIF IS COOL.

Some hotkey remapping, git prompt, completion

I am still learning tmux but here's my .tmux.conf. I've made a few common changes to make the hotkey creation of windows easier.

#remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind | split-window -h
bind _ split-window -v
unbind '"'
unbind %
bind k confirm kill-window
bind K confirm kill-server
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
bind r source-file ~/.tmux.conf

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on
set -g default-terminal "screen-256color"

I'm using the default Ubuntu .bashrc that includes a check for dircolors (more on this below) but I added this for and a git prompt, as well as these two alias. I like being able to type "desktop" to jump to my Windows Desktop. And the -x on Midnight Commander helps the mouse support.

alias desktop="cd /mnt/c/Users/scott/Desktop"
alias mc="mc -x"
export CLICOLOR=1
source ~/
PS1='\[\033[37m\]\W\[\033[0m\]$(__git_ps1 " (\[\033[35m\]%s\[\033[0m\])") \$ '

Git Completion can be installed with:

sudo apt-get install git bash-completion

Ubuntu Mono font

I really like the Ubuntu Mono font, and I like the way it looks when running Ubuntu under Windows. You can download the Ubuntu Font Family free. Right click the downloaded TTF files and right click and "Install," or drag them into C:\windows\fonts. Then click the upper left corner of any Bash console window and change your font to Ubuntu Mono.

Ubuntu Mono

Nice directory colors (DIRCOLORS/LS_COLORS)'

If you have a black command prompt background, then default colors for directories will be dark blue on black, which sucks. Fortunately you can get .dircolors files from all over the wep, or set the LS_COLORS (make sure to search for LS_COLORS for Linux, not the other, different LSCOLORS on Mac) environment variable.

I ended up with "dircolors-solarized" from here, downloaded it with wget or curl and put it in ~. Then confirm this is in your .bashrc (it likely is already)

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

Download whatever .dircolors file makes you happy (make sure the filename ends up as ".dircolors," so you may need to cp yoursourcefile ~/.dircolors and then restart your console.

Make a big difference for me, and as I mention, it's totally, gloriously, maddeningly configurable.

Nice dircolors

Leave YOUR Linux on Windows tips in the comments!

Sponsor: Did you know VSTS can integrate closely with Octopus Deploy? Watch Damian Brady and Brian A. Randell as they show you how to automate deployments from VSTS to Octopus Deploy, and demo the new VSTS Octopus Deploy dashboard widget. Watch now

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
April 14, 2017 3:07
Wow. A DesqView reference. Extended memory FTW.
April 14, 2017 3:10
This is so nice.
That feeling when developing Controller/Actions in .Net Core on windows feels like you are hacking into the FBI is awesome...
April 14, 2017 4:18
Nice post and very useful. It'll be interesting to see where WSL ends up. There's a lot of grumbling that Apple has ignored developers with its latest Macbook (no escape key, what's that about?!) but the non MS folk have been a bit snooty about Windows in the past. WSL will hopefully pique the interest of the hipsters :-)

I think even if you're primarily a Windows user WSL has features you might want to use. The great thing about Linux is there's so much built in that's convenient for a developer - for example, contrast setting up SSH on linux - one line "ssh-copy-id" compared with setting things up using Putty which is a bit of a chore.

That said WSL still feels like it's a proof of concept at the moment - I hope it's not and becomes a core part of the developer's arsenal but folks seem curious rather than ecstatic about it. I'd be interested to see any stats on how much it's being taken up. Perhaps you guys could use it a bit more at dev conferences and talks. I noticed on Twitter Charles Nutter has ditched his Mac after 10 years, maybe get someone like him to give a Ruby talk using WSL! Just a thought :-)

April 14, 2017 6:40
Or.... install emacs.
April 14, 2017 6:45
I got super excited when I spotted the BCE thing in the vimrc. It solved a long-standing minor annoyance I've had with vim in tmux.
April 14, 2017 7:31
Your tweets yesterday showing this motivated me to play around with the WSL a bunch today with .NET Core. I ended up writing a post on how to get ASP.NET Core apps to run on WSL which is a very easy way to test run your .NET Core apps on linux without having to explicitly move them elsewhere or run them on a VM or Docker. Very cool how that works. Post is here: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)
April 14, 2017 8:56
Re: WindowsIsCompletelyMissingTheTextModeBoat

I think the whole point Mr Gates made was to surround a user with 'friendly'(or not) windows to make less-keyboard-savvy people comfortable with a computer.

So... maybe we can have a special version of Windows that can be renamed Characters for us keyboard wizards.
April 14, 2017 9:41
Never got used to tmux, especially considering how hard it is to setup mouse properly on it.

However, I like how you can split screens into multiple areas and quickly move windows between them, so I wrote a tool in C# to do exactly that with GUI apps. Literally published it yesterday for the first time.

I'd be proud if you check it out:

Cool thing is that you define your screen layout in WPF's XAML. Started working on it, because my favorite GridMove is no longer developed anymore.
April 14, 2017 10:08
WSL is great, I use it since I moved to Windows 10. But I really miss the CTRL-V command. It's working on standward cmd prompt but not on the bash one. I can't tell why :-/
April 14, 2017 10:17
Great write-up, I can't wait to try it!
It would be nice to have a more modern terminal console, a-la Terminator, the current one is a bit rudimentary, but they are getting there.
MS, give-it tabs + split views and my soul is sold!
I currently use ConEmu, but there is a lot of configuration to be done to make-it proper.
April 14, 2017 11:12
But.. why not just install Ubuntu?
April 14, 2017 12:36
I have a problem with connection to DB

My connection string is

And my ASP.NET Core application, launched form Ubuntu on Windows, throws an exception:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 25 - Connection string is not valid) --->
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address

This app launched from Windows works fine.
If I change conn. string like this
Server=[Remote IP address];Database=dbname;User=login;Password=pass;MultipleActiveResultSets=true
It works fine from Ubuntu.

I think, it has some problem with connection string which conatins instance of DB.
April 14, 2017 12:40
I have a problem with connection to DB
My connection string is

And my ASP.NET Core application, launched form Ubuntu on Windows, throws an exception:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 25 - Connection string is not valid) --->
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address

This app launched from Windows works fine.
If I change conn. string like this
Server=[Remote IP address];Database=dbname;User=login;Password=pass;MultipleActiveResultSets=true

It works fine from Ubuntu.
I think, it has some problem with connection string which conatins instance of DB.

(formatting was added)
April 14, 2017 15:48
Great article, glad to see things moving along with WSL, and thanks for the tips. I am going to try to get my Ruby on Rails projects running and see how that goes.

I tried to upgrade my current 14.04 LTS to 16.04 LTS, but found out that full functionality of 16.04 is really only in the Creators Edition of Windows, so you may want to mention that to folks before they try "sudo do-release-upgrade" and it gets them nowhere (at least that's where it got me).
April 14, 2017 17:06
My experience on trying to follow this guide is good until the portion where I need to setup git prompt and the dircolors.

On git prompt, the step where is required, it was complaining (even after running sudo apt-get install git bash-completion) when I ran source .bashrc to reload the bash setting. I had to google up where I can get and finally I tried downloading and mv it to ~/ That seems to work.

On the Ubuntu Mono font, once you download the files from the repo in Windows (not in bash), just install each font (*.ttf) by opening it one by one by clicking Install in the preview or drag all of them to C:\Windows\Fonts folder to get it installed. Once that is done, open up the property of your Bash console and change the font from there to Ubuntu Mono. That should do it.

On dircolors, going to the GitHub repo, didn't quite help either. No clear instruction on how make this work. I ended up cloning the repo in ~/dircolors-solarized and doing cp dircolors.256dark ~/.dircolors to finally get it to work.

Another caveat... I tried this on trusty (Ubuntu 14.x) and the .tmux.config set -g mouse ... line will scream at you.

Better to do the upgrade to xenial (Ubuntu 16.x) first. And lastly, you should really upgrade to Windows 10 Creator Update before trying this. Because when trying to do lxrun /uninstall /full and lxrun /install keeps installing trusty instead of xenial when I tried. Couldn't get it to upgrade to xenial at all and sudo do-release-upgrade on trusty kept crashing after certain point, not sure why.

Hope that helps for Ubuntu newbies like myself :)
April 14, 2017 18:07
Great post Scott! I've played with the previous Bash on Ubuntu on Windows (or WSL, which BTW needs a better name so my Google/Bing searches work better, sigh) and need to experiment more. Gotta try DesqView now. It's awesome to see the integration of the two environments and this release has made a lot of progress. I love using my familiar *nix tools along side PowerShell and even Command shell. I only wish I had more time to put it to it's paces. Thanks for sharing with us.
April 14, 2017 18:29
@Ken Watson,

Thanks for the tip about full functionality of 16.04 only being available in Creators Edition. I suspected that would be the case but your comment has saved me a bunch of time confirming that.
April 14, 2017 19:59
Great guide - and couldn't agree more with sentiment that there doesn't need to be a "only command line" or "only GUI" development. Try a little of everything and choose what works best for you. Like Scott I find myself sometimes in command line only tools (node.js development or working with containers), and sometimes in Visual Studio land (Web APIs, C#). Sometimes PowerShell is awesome, and other times bash is perfect for the job.

If you haven't tried the tools above I'd recommend giving them a shot.
April 14, 2017 20:04
A bit of frustration. Uninstall/Reinstall still yielded Ubuntu 14.04. do-release command not found. What next?
April 14, 2017 20:38
Made the vim and ls color changes. Wow, big difference. Started using tmux. Very, very cool. So, I had this idea, why not make that my default and always run it when opening bash. (probably not a new idea for some of you experts). A quick Bing gave me this ArchLinux wiki page on tmux. Short answer, make small a change to your .bashrc, adding these line just below the case/esac statement for '#If running Interactively...', like this:

# If not running interactively, don't do anything
case $- in

# If tmux isn't already running start it
[[ -z "$TMUX" ]] && exec tmux

Bam! Now, according to Microsoft naming convention, I have "tmux on Bash on Ubuntu on Windows".
April 14, 2017 22:16
@glenn Wait, sudo do-release-upgrade gives you command not found? Strange. You can probably get the same results by changing the release in /etc/apt/sources.list and running sudo apt update && sudo apt full-upgrade
April 14, 2017 22:51

LocalDB (as the name implies) is local to your application (ie no TCP, only named pipes). As far as I know, there is no LocalDB for Linux. But, who knows in the future as SQL Server is already running on Linux.

Setup instructions for SQL Server under Ubuntu is here:

However, I was not able to install and configure the server under WSL. It failed in point #4 (got core dumped)

In your case I would recomend using SQL Server Express running under Windows.

For more information about LocalDB read her:

// Ronny
April 15, 2017 3:17
My main issue so far with working this way, is the performance.

Serving files from /mnt/c/ rather than /home/ is significantly slower, and makes it almost not worth it for me.

Any ideas to speed this up? Best I've found is using unison to sync files from /mnt but that's hardly ideal, as it's not instant.
April 15, 2017 16:09
With all the due respect (really), if you like that so much (and I can completely agree with you, Scott, believe me!), why don't use Linux directly in a native environment? This really goes beyond my comprehension.
Seems that you found a geek's "Eldorado" (and it is of course) That "Eldorado" is available from early '90 years...
Trust me, I am an old just retired IT and I worked in many environments, not excluding Windows and Linux course, but this seems to me a bit a forcing.

I really would like hear an answer from you on that, please!

April 15, 2017 19:53
WSL is a good idea right up until you realise that WSL updates are tied directly to the OS. That doesn't fly in an Enterprise org, where you may not see an OS update until six months after release.

It would be nice to use new Win10/S2016 features (WSL, Docker), but unless you're working at Microsoft or a startup, it seems like there's a booby-trap at every corner (WSL bugs persisting for six months because WSL can't be updated until the OS is updated, Docker not actually supporting any of the features required to use Docker as a service platform [swarm, overlays], etc.)
April 16, 2017 18:20
I'm a big fan of the ranger file manager. Miller columns are the best way to browse a tree structure.
April 17, 2017 16:42
For me, the biggest boost to my usage for WSL was to install ConEmu, zsh, oh-my-zsh, and change the startup command to "bash ~ -c zsh -cur_console:p". This causes me to start up my sessions in zsh, which I've grown accustomed to. I definitely prefer tmux to ConEmu's tabs. Tabs are great for different shells (one with zsh, one with PS), but for having multiple sessions of the same shell, it's not as good. I've added in the steps mentioned here to make it even better!
April 17, 2017 22:21
Great write up Scott. I personally moved from OS X to Windows 10, mostly because I joined Microsoft :), and WSL has been key helping me to setup a more friendly environment.

I've been blogging about it as well, currently using WSLtty (MinTTY version for WSL from MinTTY folks themselves) as my terminal emulator combined with tmux.

April 17, 2017 22:37
Great write-up, here is a tip I have been using to just keep some familiarity between consoles.

If you want your prompt to mirror posh-git you can use the following.

wget -O ~/

In your ~/.bashrc:

source ~/
PS1='\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$'
April 18, 2017 2:59
Tetractys - I didn't discover it, I used a similar environment when I used *nix myself in the 90s. You're saying "why not just use Linux?" Simple. I don't like the Linux desktop environment. I don't like its dodgy device driver support. With this system, I get the best of Windows AND the best of Linux.
April 18, 2017 14:48
If you want to make the transformation feel even more complete:

But unfortunately while this brings a lot of great tools to the Windows world, anything Windows-subsystem-for-Linux is Windows 10 only, and thus inevitably suffers from the same complete lack of control, privacy and ultimately confidence that finally pushed me to grit my teeth and push through the rough patches to properly 'convert' to Linux in the first place.
April 18, 2017 15:13
@Nathan Chere

Swan Desktop is based off Cygwin, and as such, loses the advantages of the WSL. However, you're missing the point here. We can argue over whether or not your concerns about control and privacy are valid, but the important point here is that the WSL meets the requirements. It lets people have access to the various userland binaries as well as the familiar Windows desktop environment and toolchain people are productive with. If you can give a reason why Swan is better than the WSL, maybe people would switch.
April 18, 2017 15:42
WSL is great, I use it since I moved to Windows 10. But I really miss the CTRL-V command. It's working on standward cmd prompt but not on the bash one. I can't tell why :-/
April 18, 2017 16:16
Scott, I am just guessing based on what seemed to work for me. But bash completion stuff doesn't work based on your instructions using a clean install.

So add the following to .bashrc?
source ~/
source ~/.git-completion.bash

Also, would be helpful to say where to get these:
wget -O ~/
wget -O ~/.git-completion.bash
April 19, 2017 20:49
Bash doesn't seem to see my vpn connection on windows. Is there a way to get the bash shell to play nice with the vpn?
April 20, 2017 0:49
Thanks for the tutorial. As a developer who's been bouncing back and forth between Windows and Linux for over a decade, it's crazy to see this coming from Microsoft. "Snowball in hell" describes it nicely.

Looking at how much you've tweaked tmux, you might want to check out byobu. It's basically a wrapper around tmux that provides nicer shortcuts, mouse support and a handful of other useful stuff. (And it's available as an Ubuntu package).
April 20, 2017 18:48
The last version of WSL is great, everything I do on Linux I can do on Windows with a impeding problem:

The filesystem speed is just not there. Cant work with things 5-10x slower.

Once that is fixed it will be awesome.
April 20, 2017 23:40
I loved your step by step congratulations
April 21, 2017 5:22
Hi, Scott

Did you mistyped ā€œ_ā€(underscore) for "-"(dash) in splitting tmux vertically?
April 21, 2017 11:18
My tip: I highly suggest ditching conhost and it's associated command window in favor of wsltty until the Microsoft team releases a really great terminal. Wsltty is based on mintty and already has some leading edge features like sixel support. Combine it with TMUX mouse support as Scott suggests above, and it's probably the best option for now.

@Pete Smith,

Awesome tip on RANGER. I hadn't seen that before. So much better than `mc` for vi users.

@Scott Hanselman

Thank you for all of the progress you're making on WSL... Still a long ways to go, but many of the basics are there.

April 22, 2017 2:46
Just a thought, may want to take a look at the git bash prompt... since most of my time is in a bash prompt in a git directory, it's been helpful to me.
April 22, 2017 6:57
Changing dircolors was great but the Windows Bash terminal prompt still shows the hideous blue color as you navigate through the file system directories. Anyone tips on changing this to match the lighter blue directory color outside of the prompt?
April 22, 2017 15:24
Scot, I just saw the VS 2017 launch video.
I am writing just to thank you for inspiring me not only professionally (technically) but personally as human being as well, with your humbled way of doing this presentation.
This is something that is not's just something one has or not.
Good luck in everything.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.