X11 on Windows

I have several Linux devices at home for testing and I like to have the ability to log in via ssh with forwarding to allow me the ability to start X11 programs and have them appear on my local workstation.

In the past I’ve used an install of Cygwin X11 to handle this need but that is problematic — every time I reinstall Windows (and I do often as an Insider) I have to go through the install and change permissions to get things to work.

During this most recent install of Windows I decided to try something different.  I downloaded Xming (and the fonts packages) as a small and easy X11 server.  I then just used Putty to connect to my Linux boxes.

Then it hit me: Win10 now has the Bash on Ubuntu on Windows subsystem.  This is a fully-functional version of Ubuntu’s userspace system which includes a full Bash shell and SSH client!

I made a few changes to the .bashrc for personal preference:

# color definitions
red='\e[0;31m'
RED='\e[1;31m'
green='\e[0;32m'
GREEN='\e[1;32m'
yellow='\e[0;33m'
YELLOW='\e[1;33m'
blue='\e[0;34m'
BLUE='\e[1;34m'
magenta='\e[0;35m'
MAGENTA='\e[1;35m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
white='\e[0;37m'
WHITE='\e[1;37m'
nocolor='\e[0m'

if [ "$color_prompt" = yes ]; then
    PS1="\n${red}${debian_chroot:+($debian_chroot) }${green}\u@desktop${nocolor} \W\n\D{%I:%M%P} [\#] >> "q
else
    PS1="\n${debian_chroot:+($debian_chroot) }\u@desktop \W\n\D{%I:%M%P} [\#] >> "
fi

# aliases
alias ll='ls -Flash'
alias la='ls -A'
alias l='ls -CF'
alias xt='xterm -bg black -fg PeachPuff -fn 8x13 &'

# change the directory sort (hidden before visible)
export LC_COLLATE="C"

# set the display for X11 forwarding
export DISPLAY="127.0.0.1:0"

I change the color of the desktop\user area depending on the server to make it obvious which machine I’m accessing.

Leave a Reply

Your email address will not be published. Required fields are marked *