Exploring Plan 9 from Bell Labs

Hang on tight guys, ’cause we’re going into Placebo Autism territory. We’re going to be exploring some esoteric operating systems that virtually no one knows or cares about. 😛

Yeah, I’m what you might call a digital explorer. I like to explore different operating systems, programs, and languages, and learn about them by just messing around with them and seeing what happens. I thrive on novelty. I’m the kind of person who likes to open up binary files in a hex editor to see what’s inside them, or open up PDF files in Vim to see if there’s any hidden code in there (hint: there is). I’ve used a diverse range of programming languages, from Commodore BASIC to Fortran to Vimscript to Common Lisp. And of course I regularly try out strange new operating systems in VirtualBox.

In the last couple days I’ve been exploring an operating system called Plan 9 from Bell Labs, or Plan 9 for short. Plan 9 was Bell Labs’ planned successor to the Unix operating system, and it took a lot of concepts from Unix and extended them to other domains. The major caveat here is that Plan 9 is not Unix. It’s an entirely different operating system, designed with graphics in mind.

Now for a little technical detail: Plan 9 is what’s known as a distributed operating system. That means there are several different modules, which may be running on separate computers. When you first install Plan 9, you install it on a single computer. This is called a standalone terminal. Afterward, you have the option of extending Plan 9 to multiple devices. These devices can act as CPU servers (nodes that perform computation) or file servers (nodes that serve files). Filesystems for Plan 9, such as kfs and Fossil, are designed to work as file servers.

I don’t have an entire network of free machines to set up a Plan 9 network, so I’m just using a standalone terminal running in VirtualBox. Plan 9 has a live boot option, which is what I’m using as it’s simply the easiest option for just messing around with a system.

Booting up Plan 9 we get a series of console messages. Here we select things like the mouse port, screen resolution, and type of monitor:

Plan 9 from Bell Labs screenshot

Plan 9 from Bell Labs screenshot

I selected all the default options and was brought to the following screen:

Plan 9 from Bell Labs screenshot

Realizing that I had the option to set the exact dimensions of my real monitor, I went back to the boot screen and entered these dimensions before reloading.

Plan 9 from Bell Labs screenshot

This causes Plan 9 to load an interface like this:

Plan 9 from Bell Labs screenshot

That’s more like it. Now I don’t have to work within the cramped confines of the default resolution. I can take full advantage of the actual resolution of my monitor.

What you see here is the Plan 9 windowing system, called Rio. Plan 9 does not use X like Unix. The windowing system has been completely redesigned from the ground up so that it’s integrated into the operating system. The large window below the welcome message is an instance of Acme – a combination text editor and file manager for Plan 9.

One of the first things you’ll notice when trying to use Plan 9 is that the mouse buttons don’t work the way you expect them to. That’s because Plan 9 has repurposed them so they each serve a special function, completely different from what you would find in conventional operating systems like Windows and Linux. The left button is used for selecting things, whether it’s selecting windows or selecting text. The right button is used for doing things with windows based on a drop-down menu that you get if you right-click on the desktop. The middle button is used to execute commands after selecting them with the left button.

Plan 9 from Bell Labs screenshot

The above screenshot shows the Acme program with an email displayed in the lower panel. This email has an embedded image, which is opened using the Plumber program.

We can close this window by right-clicking on the desktop, selecting Delete from the menu that pops up, and then right-clicking on the window. After doing this I want to create a new window to launch programs. All programs in Plan 9 are launched from the terminal. The way to open a program or file is to create a new terminal window and go to the rc prompt (rc is Plan 9’s command shell), then navigate to where the program or file is in the filesystem and type the name of the program we want to open. If we’re calling a command line program, it will open in the shell and run until we type Ctrl+D. If we’re calling a graphical program, that program will literally replace rc in the window.

With this in mind, here is a demo of opening a new Acme window. First we right-click on the desktop and select New:

Plan 9 from Bell Labs screenshot

The next step is to select the area the window will occupy. To do this, we right-click on the upper left corner of the window, then drag until we reach the bottom right corner, then release the mouse.

Plan 9 from Bell Labs screenshot

Now we have an rc terminal window, where we can type acme to open the Acme program.

Plan 9 from Bell Labs screenshot

The rc command prompt will then be replaced by the Acme program.

Plan 9 from Bell Labs screenshot

I’m going to create three new windows:

Plan 9 from Bell Labs screenshot

As you can see, I’ve opened up a man page in one terminal window and I’ve listed all the programs in /bin in another window. Now that I was acquainted with the interface, I wanted to start exploring some of the programs that were available on Plan 9, starting with the kbmap program, which you can see here. It has a listing of all possible keyboard layouts and lets you select different ones.

I also tried out the histogram program, which seems to be unique to Plan 9. You enter numbers and it creates a line graph for those numbers, much like the graphs of CPU activity in the top left corner (in fact I’m thinking those might be created using histogram).

Plan 9 from Bell Labs screenshot

I also wanted to figure out how networking works in Plan 9. I started by listing the TCP/IP servers available in /bin/ip:

Plan 9 from Bell Labs screenshot

Plan 9 has a lot of features to enable networking and server administration on a Plan 9 network. However, I’ve had a lot of trouble finding any information about networking outside the immediate LAN. I found this page on network configuration, but it only tells you how to set up LAN networking. It says nothing about how to connect to the Internet. The only article I can find that pertains to that is this one, which tells you how to configure a dial-up modem. It seems Plan 9’s networking capabilities haven’t been upgraded since the 90’s or possibly early 2000’s and any kind of modern Internet use requires a lot of hoop jumping to set up.

I was trying to figure out how to communicate with servers on my real (wired) network. In case you don’t know, the default network configuration for VirtualBox VM’s is NAT, which means each VM is essentially on its own virtual LAN with its own address space. So to communicate with say my NAS server using SSH I would have to either reconfigure the VM to run in Bridged mode, or find some way to get internetwork communication working in Plan 9.

VirtualBox network settings screenshot

I checked the network configuration for the VM and it looks like I can set up a Plan 9 server on the VM by either switching to Bridged mode or implementing some port forwarding rules. This might be an interesting project at some point.

I wanted to try to communicate with the outside LAN. I started by pinging my NAS server. No luck.

Plan 9 from Bell Labs screenshot

I then went on a little diversion and tried out the terminal-based mail program. I opened the attached image by typing 1.2 at the mail prompt.

Plan 9 from Bell Labs screenshot

Going back to networking, I checked the first article I linked to and typed ipconfig at the rc prompt to activate IP networking. At this point I did get a response when I pinged. Also, the ping messages use a literal μ character for the microseconds, which I think is pretty cool. This is easy to implement as Plan 9 uses Unicode encoding throughout the system.

Plan 9 from Bell Labs screenshot

As you can see, the ping was successful. However, when I tried to SSH or Telnet to the server, it failed.

Plan 9 from Bell Labs screenshot

I wanted to determine why this was, so I ran traceroute.

Plan 9 from Bell Labs screenshot

It seems Plan 9 is not accessing my NAS server at all. It’s going through the address 10.0.2.2, which seems to be a network address for one of its modules (makes sense that each module would have an IP address if it’s supposed to be distributed). The addresses of the servers and routers on my real networks seemed to be ad hoc network addresses virtualized by Plan 9 and not addresses of real hosts at all.

Just for good measure I ran nbd/dns -r to set up DNS.

Plan 9 from Bell Labs screenshot

In case you’re wondering, the line of white text on a black background is a kernel message. Plan 9 displays messages from the kernel on the screen, on top of the GUI. These can be somewhat annoying if a lot of kernel messages accumulate and they don’t go away, but I’ve realized that moving the windows under the messages effectively erases them from the screen.

Plan 9 from Bell Labs screenshot

The screenshot above has a couple new things in it. First, I’m viewing a sample networking database in Acme. This shows the syntax used for the local network config file, which is used to specify the domain names, hostnames, and IP addresses of all hosts on the Plan 9 network. I assume this would include all CPU servers, file servers, and workstations on the LAN.

The other thing you’ll see in the above screenshot is the location of the games directory. Unlike /usr/games in Unix, /bin/games in Plan 9 contains mostly graphical games. Here’s Sudoko:

Plan 9 from Bell Labs screenshot

And Mahjongg:

Plan 9 from Bell Labs screenshot

Then there’s CatClock, which isn’t so much a game as an animation. It’s a rather creepy-looking animation too, with this maniacal-looking cat moving its eyes back and forth as its tail swings like a pendulum. It’s sort of reminiscent of the Cheshire Cat from Alice in Wonderland.

Plan 9 from Bell Labs screenshot

Lastly, I wanted to try out some shell scripting in Plan 9. The rc shell has its own scripting language which is similar to shell scripting in Unix, with a few key differences. The main difference that I know of is that all shell variables are arrays of strings, as opposed to individual strings. You can find a guide to the rc shell scripting syntax here.

Plan 9 from Bell Labs screenshot

I only did a very cursory exploration of shell scripting in Plan 9. I couldn’t figure out how to save files in Acme, so I just tried out some control flow constructs directly on the command line. The above screenshot shows the shell executing a rather simple for loop.

Overall, Plan 9 isn’t something that has a lot of practical value. It’s not a marketable skill, and you can’t get a job as a Plan 9 admin. It’s more of an intellectual curiosity than anything else. It is basically a research operating system after all, and research operating systems are valued more for their academic appeal than anything else. Plan 9’s unique approach to the operating system interface makes for a rather stimulating computing experience, though you have to be patient to learn the ropes.

Maybe someday when I have my own place and a lot more money than I have now, I’ll create a real-life Plan 9 network and open it to the public. There’s a list of public Plan 9 networks/servers on this page, though that site is archived, so it’s impossible to tell if any of these servers are still running. It would be cool to create my own and just let other people in the Plan 9 community create accounts and use it remotely. Anyway, that’s all for today. Happy digital explorations!

Leave a comment