If you’ve ever thought about running Unix programs on your Mac, you might have assumed that meant you were stuck with the command-line interface. But you aren’t. Go to Leopard’s Applications: Utilities folder and double-click on X11.app. That will open xterm. At first, you might think it’s just another command-line tool like Mac OS X’s Terminal. But xterm is actually a gateway to something much bigger: the X11 graphical computing environment.
From X11 (which runs side by side with Mac OS X’s native Aqua environment), you can run a host of graphical Unix programs—applications that haven’t been fully ported to Mac OS X—as well as applications on remote Linux or Unix systems. Here’s a quick look at X11 and a few of the things you can do with it.
(Note: If you’re still running Tiger, you won’t find X11 installed by default; you’ll have to insert your Mac OS X install discs, run the Optional Installs package, and install it from there.)
Where to Get X11 Programs
The OS X install of X11 comes with a few programs of its own. For example, type
/usr/X11/bin/xeyes & at the X11 command-line prompt, and you’ll open xeyes, a little program that puts a pair of animated eyes on your X11 desktop; move your cursor, and the eyes will follow it. Type
/usr/X11/bin/xcalc &, and you’ll get an X11-based calculator. To get a list of the X11 programs that come with OS X, type
ls /usr/X11/bin. You can then get more information about any of the programs listed there by typing
man program name
. That will summon the Unix manpage viewer and the text-only documentation for that program.
To be honest, the X11 applications that come with OS X aren’t all that exciting. To get more interesting ones, you have to download them.
The X11 program that I most highly recommend is GIMP (GNU Image Manipulation Program). It’s a great image editor that’s actually comparable in some ways to Adobe Photoshop. If you download it from gimp.org, you’ll get a huge pile of source code that you’ll then have to build into an operable program. It’s far easier to download the GIMP binary from Wilbur Loves Apple. There, you’ll find GIMP 2.4.5 for both OS X 10.5 and 10.4 (Intel and PowerPC). Once you download that, you can just open the disk image and copy Gimp.app to your Applications folder.
While GIMP may be the best-known X11 program that will run on the Mac, there are hundreds of others worth checking out: Inkscape is a free vector-drawing program similar to Adobe Illustrator. If you want to run Microsoft Internet Explorer on your Intel Mac, you can do so with ies4osx, an X11-based application that uses the Wine Windows emulator to run any of four different versions of Explorer. (ies4osx uses a Mac-specific variant of Wine called Darwine, which is provided as a download on the ies4osx site along with ies4osx itself.)
Finally, if you really want to explore the world of X11 software, you can download and install either MacPorts or Fink. Both are open-source applications that attempt to catalog and help you install dozens of different X11 programs. But be warned: If you’re not familiar with the command line and Unix file management, don’t bother with either of them.
Whatever applications you want to try, you’ll notice immediately that they have their own look-and-feel, and it’s different from OS X’s.
For example, if you open GIMP, xcalc, and xeyes at the same time and then switch between them, you’ll notice that the X11 menu bar at the top of the screen remains the same no matter which application has the focus. If you can get used to not zipping up to the top of the screen to find a program’s menus, you should do just fine with X11.
Individual X11 programs often have menus and other interface elements of their own in addition to that overall X11 menu bar, and those elements aren’t consistent from one program to the next. For example, to open a menu in xterm, you control-click; other programs display their menus at the top of their own windows.
Other interface conventions vary in X11. For instance, most of the time you can highlight a text selection in an X11 application, and select Edit: Copy or press command-C to copy it. However, when you switch to another X11 program to paste in that selection, you’ll notice that the Edit: Paste menu item in X11’s global menu is grayed out; command-V won’t do anything. Instead, each X11 application uses its own pasting command. Most commonly, you’ll press the middle mouse button to paste; if your mouse doesn’t have three buttons, go to Preferences: Input, select Emulate Three Button Mouse, and follow the instructions.
Running X11 Remotely
If you have access to a remote Unix or Linux system (either in your office or on the Internet), you can connect to it via Secure Shell (SSH) and then run remote X11 applications that will display on your Mac’s desktop.
For this to work, the remote computer needs to be configured to permit SSH logins and to allow X11 to run over SSH. To do this, open xterm and type
ssh -X username@hostname
(replacing username with your remote user name and hostname with the host name or IP address of the remote computer). Log in with your password.
That done, try running an X11 application: xterm, xeyes, Firefox, or anything else that’s installed on the remote system. Depending on the speed of the connection, that application should open fairly quickly. If you get the message “error: Can’t open display: DISPLAY is not set,” this usually means the administrator of the remote computer needs to enable the X11 Forwarding option in the sshd_config file before you log in.
Brian Jepson is the executive editor of Make magazine’s book series and the coauthor of Mac OS X for Unix Geeks, fourth edition (O’Reilly, 2008).