Bash for Windows 10 has been out for almost a year now. It has been incredible for a developer like myself to be able to use Bash natively on a Windows machine!

In this article, I’ll show you how I install my main Bash setup for Windows 10.

 

Requirements

  1. Your Windows 10 PC must be running a 64-bit version of Windows 10 Anniversary Update build 14393 or later.
    To find your PC's CPU architecture and Windows version/build number, open Settings>System>About. Look for the System type and OS Build fields.


    In this screenshot, I have a 64-bit operating system, x64-based processor and OS Build, 15063.138, so I fit the requirements.

 

Steps

  1. Install Bash on Windows 10
  2. Install ConEmu for tabs
  3. Must have Bash customizations
  4. Install VcXsrv Windows X Server for opening GUI applications

 

1. Install Bash on Windows 10

In order to run Bash on Windows, you will need to manually:

  1. Turn on Developer Mode
  2. Enable the “Windows Subsystem for Linux (beta)” feature

Open Settings -> Update and Security -> For developers
Select the Developer Mode radio button.

Developer mode is selected.

From Start, search for “Turn Windows features on or off” (type ‘turn’)
Select Windows Subsystem for Linux (Beta)

Windows Subsystem for Linux (Beta) is checked.

Hit OK. Installation will proceed, and afterwards, you will have to restart your computer.

After you restart your computer, you will be able to finish installing Bash on Windows 10.

From Start, search for “bash” (type ‘bash’)

When you open bash, you will see a command prompt window.

Type "y" to continue.

The real “Bash on Ubuntu on Windows” shortcut will be installed.

Now, you can open “Bash on Ubuntu on Windows” whenever you search for “bash”

Try opening Bash.  The first time you install Bash on Windows, you will be prompted to create a UNIX username and password.

After typing in a UNIX user name and UNIX password, you can use Bash the same way that you would use a terminal on Mac and Linux.

The biggest problem though is there are no tabs! Let’s fix the tab issue.

 

2. Install ConEmu for tabs

ConEmu is an amazing program that gives you terminal tabs, allows you to copy and paste the normal way with CTRL-C and CTRL-V, and run any combinations of shells including Command Prompt, Bash, Powershell, and more.

https://conemu.github.io/

Hi the Download button, which will take you to a redirected list of versions of ConEmu. I like to use the Preview version.

Run the executable. Select the x64 bit version of installation.

Hit Next on the next few prompts, which are the intro window, license and agreement, and settings. I leave everything by default.

Now, you are ready to install. Hit Install.

Hit Finish on the next prompt.

From Start, search for “ConEmu” (type ‘ConEmu’)

When ConEmu first starts, you will be brought to the Startup Settings. You have to select the default console that you want to open.

Find and select {Bash::bash} in the Specified named task section.

Now, whenever you open ConEmu, it will open to Bash by default! ConEmu is easy to read and smooth.

I like to pin ConEmu to the taskbar to be able to open bash quickly. Right click ConEmu’s icon and click Pin to taskbar.

To add a new tab on ConEmu, type WIN+W.

To switch to the right tab, type CTRL+Tab.

To switch to the left tab, type CTRL+Shift+Tab.

All ConEmu’s shortcuts are listed: http://conemu.github.io/en/KeyboardShortcuts.html

 

3. Must have Bash customizations

Bash on Windows 10 is great, but it could use a few customizations to make using it with Windows 10 files and programs easier!

First, we will adjust our ~/.bashrc.

nano ~/.bashrc

Use any text editor. On nano, type ALT+/ to go to the end of the file.

These configurations allow easy access to some of my favorite Windows related directories and programs.

I want to be able to change directory to the Windows C: drive easily and access my desktop, so I use aliases.

alias converts the given word into shortcuts.

I also want to be able to use Sublime, which is my go-to GUI text editor, so that I can type subl . and open the current working directory with Sublime.

I am using Sublime 3https://www.sublimetext.com/3

I want to be able to open any folder with File Explorer with open, so that I can open the current working directory with open .

I have a shortcut called linux to open the Ubuntu’s root folder with File Explorer.

Lastly, I have an alias called reload for reloading the ~/.bashrc to apply any new configurations.

Replace huyle with the username of your computer.

# Custom shortcuts
alias windows="cd /mnt/c"
alias desktop="cd /mnt/c/Users/huyle/Desktop"
alias subl="/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe"
alias open="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe /c start -WorkingDirectory C:'\\'Users'\\'huyle'\\'AppData'\\'Local'\\'lxss"
alias linux="open C:/Users/huyle/AppData/Local/lxss"
alias reload="source ~/.bashrc"

These other shortcuts I use to access my favorite directories. I recommend you to add your favorite Windows or Ubuntu directories where you put your development code or work.

# Optional shortcuts
alias repos="cd /mnt/c/Users/huyle/Desktop/Repos"
alias work="cd /mnt/c/Users/huyle/Desktop/Work"
alias youtube="cd /mnt/c/Users/huyle/Desktop/YouTube"

You can save your file with nano by using CTRL+O and then pressing Enter.

Now, we can apply these changes.

source ~/.bashrc

Use the windows alias to easily switch to your Windows files! You can try some of these other aliases!

open .

The open alias does not work with Ubuntu’s directories because of directory translation errors, but by default, at least, I set the alias to open the Ubuntu root directory.

Every now and then, I prefer using Sublime, so it’s very convenient to be able to type subl . in order to open current working directories with Sublime.

Here are some extra utilities that I like to install on Bash. These utilities are optional.

I like to use tmux, which is a terminal multiplexer. It lets you switch easily between several programs in one terminal.

I like tabs, but every now and then, I like everything in one terminal for a bird’s eye view.

I also like to use zip and unzip often to create zip files and extract them.

sudo apt-get install -y tmux zip unzip

Nice! Bash on Windows 10 with tabs and tmux feels so good. Your development is now super-charged!

 

4. Install VcXsrv Windows X Server for opening GUI applications

If you have ever wanted to open GUI applications through SSH connections, this step is for you.

By default, Windows 10 does not come with an X11 server by default. I’ve been using VcXsrv Windows X Server, but Xming also works.

You can download VcXsrv Windows X Server here:

https://sourceforge.net/projects/vcxsrv

Hit the Download green button.

I leave the settings by default.

You can open VcXsrv by searching for “vcx” on Windows 10 search.

I Allow access for VcXsrv Public networks.

Now that we have our X11 server open, we should adjust our ~/.bashrc a little bit to make sure that the DISPLAY value will be correct.

vim ~/.bashrc
# X11 server display value
export DISPLAY=localhost:0.0

Let’s test if our X11 server works! I like to install x11-apps for testing.

x11-apps contains xclock, which is great for testing GUI applications and X11.

sudo apt-get install -y x11-apps

Now, let’s run xclock.

xclock

Last but not least, let’s make sure that X11 will work on top of SSH connections.

mkdir ~/.ssh
vim ~/.ssh/config
Host *
    ForwardAgent yes
    ForwardX11 yes

Now, save the ssh config file and change its permissions correctly.

chmod 600 ~/.ssh/config

Afterwards, you should be able to use -X with ssh in order to enable the forwarding of X11 connections to VcXsrv.

ssh -X username@IP_address

Great job! Good luck with your development. I’ve been finding this setup very comfortable as a developer!