Running Linux in the browser

I haven’t seen it mentioned on Planet yet, could it be that nobody heard? I’ve seen lots of cool browser demos lately but this one really blows me away: jslinux by Fabrice Bellard. This is a real x86 emulator written in JavaScript and running Linux, not a fake Linux terminal. The emulated hardware is somewhat limited (e.g. no FPU) but this doesn’t make packing an emulator into less than 20 kB of JavaScript code less impressive. The emulator loads a bunch of binary Linux images and — voilà, Linux boots up.

It is also really fast, booting up takes 7 seconds in Firefox 4 for me, and all the other operations don’t take much longer than they would on a real system. Supposedly, Chrome 11 is also supported but for me it hangs up near the end of the boot process. Also, Chrome 11 is noticeably slower (Fabrice Bellard himself made this observation as well). There are plenty of command line tools available, including a compiler. I first had my doubts — but they all work as you expect them to. I can even ping (pinging other addresses or using wget fails because the emulated hardware lacks a network interface). Update: Even better: run telnetd, change root password with passwd, then telnet to and log in as root — it actually works.

Talk about desktop applications moving to the web…


  • dspace

    Interesting. Gnome 3 applications can run in the browser as well. And I think the Document Foundation is trying to make LibreOffice web friendly. Linux is well positioned for the inevitable transition to the “cloud”, although I shutter to use that word. :)

  • Charles

    ERROR: your browser is too old to run JS/Linux.

    You should use a recent browser such as Firefox 4.x or Google Chrome.”

    LOL…I’m running the latest version of Opera, I’m not using an outdated version…

    Wladimir Palant

    It is using typed arrays, Opera doesn’t support them yet.

  • Fredrik

    @Charles, you need a browser that supports typed arrays. Otherwise it’s “too old”.

  • David

    :-( On Nightly I get:

    Error: invalid arguments
    Source File:
    Line: 9

    Wladimir Palant

    Yes, I’ve seen that as well. I checked with JavaScript Deobfuscator, apparently it is having trouble using XMLHttpRequest to get binary data. It is currently trying to use mozResponseArrayBuffer (Firefox 4, older version of the standard?) or response (WebKit and V8, per standard) XMLHttpRequest property. Nightly builds no longer have mozResponseArrayBuffer but they have mozResponse rather than response (also mozResponseType rather than responseType), this is the usual approach for experimental implementations. A trivial change to the script should do.

    Wladimir Palant

    Fabrice Bellard fixed this issue now, it works correctly in Firefox nightlies.

  • skierpage

    It’s fascinating! It’s immediately the fastest and easiest environment for learning the Linux command-line. If it ever gets networking support it’s a killer network utility. I wonder if it can run Google Native Client binaries, or the planned Pinnacle portable native client format (really portable portable clients!).

    If M. Bellard open-sources it I’m sure a port of DOSBox to JavaScript will come quickly, then other 386 runtimes. Wow, just wow.

  • Simon

    @dspace: “Interesting. Gnome 3 applications can run in the browser as well.”

    Not quite true. Gtk 3 has a backend that allows applications to render to a buffer that gets sent to a browser for display. But that’s just a remote desktop like VNC – the application isn’t actually running in the browser…

  • Jay Satiro

    Impressive! The most interesting thing I’ve seen in a while.

  • njn

    Fabrice Belland is a freaking genius at this kind of thing.

  • pfg

    Fabrice has added support for Opera and ie9, and an easy way to upload “C” source programs.
    ==> We can easily compare the performance of each browser :
    1- paste some C program in the clipboard aera (just use #include <tcclib.h> instead of usual ones)
    2- type “cat /dev/clipboard >toto.c;tcc -run toto.c”
    3- measure start time – end time

    On a mandelbrot test :
    -ie9 is 10% slower than firefox,
    -both are very slow (probably due to the lack of “fpu”).

  • EriC

    It loaded in 3 secs but don’t know what to do now… :p

    1 week ago for first time in my life I installed Ubuntu 11.04 through “Wubi” in pararell with Win7 but after 2-3 times, bored entirely. Now I’ve it as secondary OS but propably I’ll delete it.