X11 (or Xwindows) is a method of remotely logging into a linux/unix machine, that has been around for longer than I care to remember. It appeared a long way before VNC, RemoteDesktop, WebEx, GotoMyPC and other remote control software. In fact, it pre-dates many windowing systems.
In the early 1990′s I used to run slackware linux on a tiny little headless PC in one room, and sit with my laptop in another room. gnuchess was running on the linux machine and the chessboard appeared on my windows laptop. VNC came around a lot later as a more general purpose way of remotely controlling the mouse/keyboard and getting a live bitmap of the screen sent over the network, but the two techniques are very different.
For those of you already bitten by VNC, it is still worth looking at Xwindows on a Raspberry Pi (or any linux/unix breed for that matter), as it offers some interesting and different modes of operation.
VNC is good, and I do use it a lot. I even use the web server applet model. Did you know you can go to http://mymachine:5800 and it downloads a java applet which runs in the browser, and you can interact with your remote machine without even installing VNC client on your computer? – if you don’t know about this, hop back to the VNC pages at  and re-read the manual, you’re not a power user until you’ve used a number of the advanced modes of VNC.
VNC is generally simpler to set up, but X11 provides other flexibility that you should at least try to see if you like it. I will add some screen dumps to this article and maybe even a little youtube video at a later date, but I wanted to get these instructions documented so that one of my teacher friends could try them out for me.
VNC vs X11/xwindows
One of the main differences between VNC and x11 is that VNC sends all mouse movements to the remote machine, and all screen updates come back as compressed bitmap data. This truly is a live remote connection at the lowest level. VNC uses compression, so this performs better than you might think, but still it’s quite an inefficient protocol if you have a poor connection to the remote machine.
X11/windows however, runs a X11 display server on the computer you are sitting at, and the programs running on the remote machine just send display update commands in to that server. This is inherently much more efficient, and more flexible. It’s not without it’s problems, but here are some of the neat things you can do with a X11 server.
- remotely log in to another machine (e.g. via ssh), run a command, and a graphical window pops up on your windows/mac desktop. e.g. on a Raspberry Pi, if you have it all set up and working, typing midori & at a ssh command prompt will start the midori browser, the midori “back end” runs on the raspberry pi, but the window appears on your windows/mac, just as if it was a normal window on that machine.
- Run multiple display servers on your windows/mac and open windows from multiple remote machines. Each window looks like a native window on the computer you are sitting in front of.
- Start the desktop server as part of the connection process, and get a complete desktop appear on your windows/mac along with the menu bar and all other assets. You can have multiple simultaneous desktops open to the same machine, or to different machines, and you can also have multiple “untethered” windows open as well.
The best discussion of what X windows is, what you can do with it and how it works, is on the official wiki page in ref 
Getting a secure shell (ssh) to your Raspberry Pi
I’ll constrain my instructions here to just on windows, but you can do the same on a Mac. There are a number of very nice pre-rolled instructions on the web explaining how to do this on the Raspberry Pi and windows, but I found they all stopped working at some point. So, I’ve written down here the steps I followed to get it all working – others might want to extend these instructions by adding some screen dumps for me.
The base for working all this out was the xming instructions in ref and Raspbian Wheezy from ref. I used Win32DiskImager from ref to store this image on a 4GB SdCard and booted the Pi from it. I then pressed escape at the blue startup screen to get a prompt.
1. Install putty
I downloaded putty-portable from ref. Putty acts as a ssh connection to your Raspberry Pi. It can also be used as a terminal to other systems, so it’s a good all-rounder app to have on your system. I installed mine into c:\PuttyPortable.
2. Check that ssh to your Pi works ok
Make sure your PC and your Pi are plugged into the same network and that you know the DHCP Assigned IP Address that your router gave to the Pi. The simplest way to do this is type this on the Pi
You will see against eth0 there is a Inet Addr entry, usually a 192.168.1.x number but might be different on your system.
In putty, type in this IP Address in the hostname, type in “pi” in the Saved Sessions, and press SAVE (you will need this again later). Then press OPEN.
First time in you might get a warning about the host key not being cached in the registry, just press YES for now.
You then see:
type in pi, press return and the default password is raspberry
You now have a shell on your windows PC that is connected to the Raspberry Pi. Anything you type here will run on the Raspberry Pi, and the results sent to this window. You can open multiple windows like this and be logged in multiple times.
Getting XWindows working
Actually, there’s not really anything to do on the Raspberry Pi, as that’s all pre-configured in the wheezy distribution. If you use startx on your Pi, then it all works anyway. The hard work starts on the other end!
3. Configure Putty for X11 forwarding
This means, when X11 requests come back over this logged in connection (more of that in a bit), they will be redirected to the program that manages those requests. For now, just follow me:
Open putty and LOAD your Pi settings.
In putty, on the left hand Category window, under Connection/SSH/X11 tick the Enable X11 Forwarding box and set X display location to localhost:0
Click back in the Category window to Session and press SAVE to save these against your PI settings.
4. Install xming for windows
xming is an X11 server that runs on windows – it accepts any incoming X11 display requests and handles those for you. Get this from ref. Install it into the default folder, and make sure the “Portable Putty” option is chosen all the other checkboxes are enabled (they should be, by default)
At this point, when it finishes and says “launch xming” – uncheck this box. On windows 7 (and probably vista), xming seems to need administrator rights to run. This was the bit that took me ages to work out (and didn’t seem to be mentioned in the xming instructions I followed). I do this by opening xming from the start/all programs/xming/xming with a right-click and “run as administrator”. You know if it has worked, because the xming icon appears in your system tray. If you don’t see the X logo in your system tray (or in the hidden icons for the system tray), make sure you really are running it as adminstratory.
5. Launching a program from putty
This is where the fun really starts. If all this is working, you should now be able to open putty as before and login to your Raspberry Pi. Then type:
This runs the midori web browser an the & at the end tells linux to run this program in the background (disconnected from the terminal window). This means you can now use the terminal window for launching other programs.
After a few seconds, a midori window should open on your windows desktop. The program is running on the Raspberry Pi but the window appears on your windows desktop!
Try this a few more times by typing midori & into your putty session, and you should now have multiple midori windows opened.
6. Full desktop mode
After you’ve had some fun with all the detatchable windows, it’s now time to get full desktop mode working. To do this, it is easier if you use the xlaunch program from the xming menu. You can leave all your existing windows open if you want, but remember these are connected to logical display “0″ on your windows machine.
start/all programs/xming/xlaunch (right-click run as administrator)
Choose “one window” and set the display number to 1
You can have any number of display servers running, but each must have a unique display number. As you have already used display 0 (you configured this in putty ssh/x11/X display location remember?), we’ll use logical display 1 for the full desktop so you can leave all your other windows open.
Click NEXT> then click “start a program”
Click NEXT> then enter startlxde in the start program box
Run remote using putty.exe
Type in the ip address of your Raspberry Pi, the username pi and the password raspberry.
click NEXT> then NEXT> then FINISH
You might get an error at this point saying “unable to load file for reading”, but just OK this, it still works regardless.
You might get asked about host key caching the first time you go in, I just pressed YES and it worked.
What you should now have is a new “windows” window with the full raspberry pi desktop inside it, along with menu and system tray.
Yet more fun
I won’t go into the details of this here, but here are some other things you could have a go at
- Why does this work even though you haven’t typed startx from the Raspberry Pi (you didn’t type that did you, I didn’t tell you to!)
- Connect together 4 Pi’s on the same network, and open up windows for each of them on your windows desktop. Remember, you need a different display server with a different logical display number for each.
- X11 makes incoming connections to your computer, why is it that if you have the firewall enabled (I didn’t turn mine off) it still works?
- See if it is possible to have multiple windows machines connecting into the same Raspberry Pi, each one with it’s own windows – how does the Raspberry Pi know where to send the window commands to?
- Can you from the keyboard/screen of the Raspberry Pi start a program that then sends it’s output to a specific remote display
Follow on work
I have tried these instructions on 3 different windows-7 laptops now and they seem to work. However, I am still waiting to gain access to my “friendly teacher” to independently try out these instructions.
When I have a bit more time, I will take a number of screen shots of the windows setup screens and insert them into the instructions so you can more easily recognise the bits of the screens I am talking about – if you look at the official xming instructions in the links below there are some nice screen shots in those.
 VNC Instructions
 Xwindows wiki
 putty portable