Hands on X11
Pages: 1, 2
In the old days, your big Unix servers ran all of the applications, and you used an X Terminal (a machine with a screen and keyboard but no hard drive or CPU of its own) to use those applications.
Today most Unix systems (Mac OS X included) still support this
functionality. Let's go back to your open xterm window. In order to
allow other systems to display their applications on your screen, you must
first give them permission to do so. You do this using the xhost program
(you can learn more about the xhost command by typing
xhost at the xterm prompt). From the command prompt in xterm, type
xhost and press return. Unless you've already modified the default
permissions of your system, you'll most likely see a message like this:
access control enabled, only authorized clients can connect
What this tells us is that your system will only let authorized
computer systems display X11 applications on your system. For security
purposes, this is a very good thing. You wouldn't want someone displaying
applications on your system without your authorization. In order to allow
other machines to do this, you need to grant them access from the prompt.
For example, I'd like to allow Gomez, a FreeBSD server without a monitor
or keyboard, to display it's applications on my Mac. Gomez's IP address
is 10.0.1.204, so I type
xhost +10.0.1.204 at the prompt, and
it responds with
10.0.1.204 being added to access control list
Alternatively, if I'm sure that my network is secure behind a firewall,
and I'm not worried about possible security issues, I could also have
xhost + at the prompt. This allows any and all
machines to use my Mac's display. The system would respond with
access control disabled, clients can connect from any host
Now I'm ready to launch an application from the remote system. I've
ssh'd to Gomez, where an entire X11 distribution and additional
applications are available to me. So, let's launch something simple,
xclock for example, and watch it appear on my Mac. I type
& at the Gomez command prompt and press return, but instead of
seeing an xclock appear on the Mac, I get this error:
Error: Can't open display:
The cause of this error is that all X11 systems, by default, will try and use their own display for any X11 applications you launch. In the case of Gomez, there is no keyboard, mouse, or monitor, and no X Server running. So I need to tell Gomez to use my Mac's display instead. The Mac's IP address is 10.0.1.2, so, from Gomez's command prompt, I type:
I use the export command for this because I'm running the bash shell. If I were running the tcsh shell, I'd have typed:
In either case, unless something went wrong, the system should return a command prompt, and you're ready to go. This command tells the remote system to use the first X Windows display running on the machine with the IP address of 10.0.1.2. In other words, it treats the Mac as if it were its very own monitor, keyboard, and mouse. Now, we type:
This time, instead of an error, Gomez returns a process number (we ran the program in the background using the & symbol) and we see the xclock display on the Mac.
Neat, but not exciting. And we've already got the xclock application
on our Mac. On this Mac, we use Safari, Camino, and Internet Explorer,
but don't have Mozilla installed. Wouldn't it be neat to run FreeBSD's
Mozilla on the Gomez and have it display on the Mac? From the command
line, we type
The server responds with a process number, and after a few moments, Mozilla appears on the Mac's screen, as shown in this screenshot. Notice the un-Mac-like fonts, and the information on the about page which lists "FreeBSD i386" as the build version. This is because Mozilla is actually running on the FreeBSD server and is merely being displayed on the Mac.
X11 can be used to manage many remote Unix systems in this fashion, an unlimited amount, actually, all the while keeping your Mac's system resources low (only the X11 application runs locally). This is very handy when running applications on Unix systems that lack a monitor and keyboard but require a graphical display. The Oracle installation program is an excellent example of this type of application.
We've only just scratched the surface of X11's true potential. Not only do you now have the ability to run a huge collection of X11 applications on your Mac, but you can also run an X11 application from any Unix system you can connect to.
Dan Benjamin is a business strategist, programmer, writer, interface designer, and photographer.
Return to the Mac DevCenter.
What Software ?
2003-08-21 16:09:32 anonymous2 [View]
X11 window too big
2003-08-19 19:40:19 anonymous2 [View]
X11 and $DISPLAY issues
2003-06-25 12:33:23 anonymous2 [View]
Problems here, too.
2003-06-13 09:14:00 anonymous2 [View]
set in tcsh
2003-05-08 12:39:29 anonymous2 [View]
X11 and SystemPrefs: Networking
2003-04-30 08:45:51 anonymous2 [View]
Yes, but how do I run Mac OS X apps through X?
2003-04-26 05:47:15 anonymous2 [View]
Something is still missing
2003-04-09 12:24:28 anonymous2 [View]
Do not use XWindows across network WITHOUT ssh
2003-04-07 20:21:36 csoto [View]
2003-04-03 08:49:16 anonymous2 [View]
2003-03-25 10:07:48 anonymous2 [View]
Cannot Find Command
2003-03-19 11:25:19 anonymous2 [View]
How to Completely remove X11
2003-03-17 23:39:12 anonymous2 [View]
2003-03-17 09:47:59 anonymous2 [View]
Use ssh -XC firstname.lastname@example.org instead
2003-03-17 07:17:35 anonymous2 [View]
2003-03-16 17:30:15 anonymous2 [View]
2003-03-16 17:26:41 anonymous2 [View]
2003-03-16 14:25:08 anonymous2 [View]
2003-03-15 13:50:26 anonymous2 [View]
I'm Getting Errors
2003-03-15 13:23:01 anonymous2 [View]
2003-03-15 06:06:29 bbum [View]
If you're going to use ssh anyway...
2003-03-14 18:13:53 anonymous2 [View]