UNIX For Dummies [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

UNIX For Dummies [Electronic resources] - نسخه متنی

John Levine, Margaret Levine Young

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






UNIX Gets All GUI

The earliest UNIX systems didn’t have fancy, screen-oriented windowing systems. They didn’t have screens at all, in fact — they used loud, rattling terminals that printed on actual paper. (The historically minded can find these types of terminals in the Computer Museum in Boston and the Smithsonian Institution in Washington, D.C. Yes, really.) As the years went by, UNIX appeared on computers that did have screens (most notably Sun workstations), and various windowing systems appeared.







Under the hood in Mac OS X


Apple programmers wrote the first nine versions of the Macintosh operating system all by themselves. But in OS X, they wised up and jumped on the free UNIX bandwagon. Underneath all of the Mac-fullness, OS X is based on a version of FreeBSD. If you look in the Utilities folder in the Applications folder, you find the Terminal program, which gives you the classic UNIX shell.

Although the Mac Finder looks a lot like some X desktops, or maybe the other way around, the OS X window system (known as Aqua) isn’t X; it’s the old Mac window system rewritten for UNIX. But if you want X, Apple is happy to give it to you. Visit www.apple.com/macosx/x11 where you can download a version of X for OS X, integrated with Aqua so you can run Mac OS programs and X programs together, and even cut and paste between them. The X programs may look a little strange on the Mac desktop, because they still look like UNIX programs, but that’s how you know it’s UNIX. Looks odd, but works great.











One thing about the UNIX community you’ve probably come to appreciate by now is that you can’t get everyone to agree on anything, except of course that UNIX is better than every other kind of system and that anyone who thinks otherwise is silly. So, not surprisingly, a variety of incompatible windowing systems arose, each different from the other in various, not particularly interesting, ways. Nearly all the windowing systems were proprietary (they belonged to one system vendor or another), and, of course, no vendor would dream of admitting that someone else’s window system was better than theirs.


X marks the window


Universities also had a bunch of window system projects. One of the more successful was the X Window project at MIT (alleged to be a successor to the W Window project at Stanford — as far as we know, no one created a V Window project). The X Window system had many virtues, not the least of which were that it worked adequately well and it was available for free to anyone who wanted it. So X became the window system everyone used.

Almost all UNIX systems that have any sort of GUI now use one based on the X Window system (frequently abbreviated to just X Windows, which has been known to drive UNIX purists crazy because it sounds too much like that other famous operating system from Redmond, Washington). Old Sun workstations used systems called SunView or NeWS; NeXT machines use NeXTStep (are tHoSE wOrDS cAPiTaLIzed corREctlY?); other than those exceptions, however, you almost certainly get X Windows.
X (which is an even shorter abbreviation for X Window system) has many advantages as a windowing system:



It runs on all sorts of computers, not just those that run UNIX.



It is policy independent: A program can make the screen look any way it wants; the screen is not constrained to a single style, as it is on the Macintosh or with Microsoft Windows. (As you may imagine, this capability is not an unmitigated blessing. Read more about this subject in “Just my look” later in this chapter.)

It uses a networked client-server architecture (love those buzzwords). You can run X on one computer, and the programs that display stuff on-screen can be on entirely different computers connected by a network.



MIT gives it away.



You can imagine which of these important advantages is the one that really made all the computer makers choose X. Even though MIT gives away the base version of X, unless you happen to be using the exact same kind of computer the guys at MIT use (or you feel like compiling and debugging a gazillion lines of C code), you don’t get it for free. You must buy a version tailored for the particular kind of screen and adapter on your computer. An exception is XFree86, a free version of X used by most PC-based UNIX systems, such as Linux, which is described in Chapter 3.

How your screen looks depends on which GUI you use. The first part of this chapter talks about things that are the same for all GUIs. Later, we talk about how to tell which GUI you are using and how to do things that work differently for each GUI.


“I’m not just a server — I’m also a client!”


X was designed from the beginning to work with computer networks. It makes a clear distinction between the server program, which handles the screen, keyboard, and mouse, and the client program, which does the actual computing. Although the two programs are running more often than not on the same computer, they don’t have to be. (Readers who saw John on The Internet Show on public TV a few years ago may recall one demonstration of an online subway map of Paris. That was an X application, with the X server running on a PC in the TV studio in Texas and the client program on a computer in France, connected by way of the Internet.) The networkability (is that a word?) of X is most useful in two ways. One way is that you can be sitting at an X workstation attached to a local network and have windows attached to client programs running on computers all over the network, often on computers considerably more powerful than yours, particularly if you’re running on an old PC. X terminals, stripped down PCs, used to run only one program, the X server, but these days PCs have gotten so cheap that they cost less than any plausible X terminal. Should you find yourself using an X terminal, it works just like a UNIX workstation except, of course, that all of the programs you run have to be on other computers.








Tip A few cool X programs


Because MIT gives away X Windows, X quickly became the standard window system at hundreds of colleges and universities around the world. Students, who have a sincere dedication to doing something other than what they are supposed to be doing (not like the rest of us — no way), quickly wrote all sorts of silly programs — nominally to test either X or their understanding of it and generally to have fun. Assuming that these programs are installed on your computer, you only have to type their names in a window containing a UNIX shell to run them (read more about this subject in Chapter 7). A few of the better-known fun X programs are in this list:



xeyes: Pops up a large pair of eyeballs that watch the mouse cursor as you move it around the screen. According to the manual, it checks up on you and reports back to the boss. Hmmm.



xsnow: Puts a snowstorm on the screen background. Snowflakes fall down the screen and pile up on top of your windows. The - santa option makes an occasional reindeer-drawn sleigh fly across your screen. Ho, ho, ho.



xsol: Plays a game of Klondike solitaire against you. You click the deck to turn over the next card and drag cards to move them around. It’s as good a way as any to learn how to handle the mouse, or at least that’s the excuse you can use when your boss comes by. Because the computer controls the card deck, you can’t cheat, which means that winning in one trip through the deck is practically impossible. We’ve won honestly once in about two years of play. The program enables you to turn over the deck and try again, which enables you to win nearly half the time, albeit without honor.



xphoon: Displays in the background of your screen a detailed, full-screen picture of the moon as it appears today. In a classic display of dedicated geek programming, it correctly computes the relative angular positions of the earth, moon, and sun based on the current time and date and shows the moon’s current phase (full, quarter, half, or whatever). It’s useful for people who work in windowless offices and have forgotten what the sky looks like.



xmille: Plays the Parker Brothers game Mille Bornes against you. It keeps a running score and plays a mean game. Click the deck with the left mouse button to draw a card, click a card in your hand to play it, and click a card with the middle button to discard it. During the past year or so, we have won 34 games and lost 42, with each game consisting of about five hands.



xroach: Lots of yucky roaches scurry around the screen and hide under the windows, just like in real life. If you run the program with the -squish option, you can squish the roaches by clicking them, leaving an authentic smudge of roach guts on your screen. (UNIX geeks consider this program to be humor at its finest.)



















We’ve got something in common


A few companies doing UNIX apparently decided that they had gone too far in the customizability department, so they got together with the Open Software Foundation to create something called the Common Open Software Environment, which describes how to build UNIX programs so that they all act and look something like each other (or at least like they come from the same planet). In 1995, this group came out with the Common Desktop Environment, or CDE, which is a UNIX windowing system that bears more than a passing resemblance to the Macintosh and (Microsoft) Windows desktops. Surprisingly, CDE began to catch on, especially among Microsoft Windows and Macintosh users who were new to UNIX or who needed to use both Windows or Mac OS alongside their UNIX workstations. CDE does much more than manage your UNIX windows. We talk about CDE in the section “CDE: A Desktop for All Seasons,” later in this chapter.

The KDE environment, which we also discuss later in this chapter, looks a lot like CDE. Because CDE costs money and KDE is free, you’re more likely to run into KDE these days.












Just my look


Most windowing systems on most kinds of computers make programs use a consistent style. All Macintosh programs, for example, look pretty much the same: They all use the same menu, the same little window when you want to select a file, and similar windows to turn options on and off. One Microsoft Windows program looks much like all the others: They all use similar sets of windows.

Do all X Windows programs have a consistent look? Of course not — that would be too easy. This situation is what the X crowd means by policy independence: X is utterly agnostic about what windows should look like on-screen, how keystrokes and mouse clicks should be interpreted, and pretty much anything else that affects a user. This lack of policy was part of the original appeal of X because no matter which window system you are used to, you can make X look just like that system. The good news is that X offers great flexibility. The bad news is that the word inconsistent barely scratches the surface of what you run into.

Makeup artists for your windows


One of the ways in which X avoids having any policy built in is that it foists much of the general window-management jobs onto a program called a window manager. (Catchy name, huh?) The window manager handles jobs such as creating borders around each application’s main windows; controlling how you move, resize, switch among, and iconify windows; and most of the other tasks that aren’t part of any particular application. It’s possible to run X without any window manager, although it’s rather unpleasant because, without one, you have no way to do some things, such as move a window.

A field guide to window managers


A bunch of competing window “looks” are on the UNIX market. To tell which one you’re stuck with . . . er, have the pleasure to use, look at the border around the windows on your screen. If they have 3-D–style borders with sharp corners, as shown in Figure 4-1, you’re using the Motif Window Manager (MWM); its free look-alike counterpart, FVWM; or DTWM, the Desktop Window Manager that comes with the Common Desktop Environment (CDE). If the borders have rounded corners, as shown in Figure 4-2, you’re using OpenLook. If they have a thin border around the sides and bottom and top borders like those shown in Figure 4-3, you’re probably using a program called TWM, which comes with the base version of X and is still sometimes used because it is simple and small.


Figure 4-1: A typical Motif window.


Figure 4-2: A typical OpenLook window.


Figure 4-3: A typical TWM window.

The Open Software Foundation, the same people who provide the OSF/1 version of UNIX, created Motif, based on some work done by their members Hewlett-Packard and Digital Equipment. Motif is much more complete than its competition (it has a provision for handling languages other than English, for example), and because DEC made it cheap for software vendors to use, it became the primary X Windows manager until KDE and GNOME came along.

People using the Common Desktop Environment (CDE) get the Desktop Window Manager, or DTWM. CDE comes with all kinds of nifty and zoomy programs, although underneath the glitz it’s just a version of Motif, so it looks pretty much the same.

Lots of other window managers exist, although the ones described in this section are the most common ones. After several years of window system warfare, Motif and its clone FVWM have emerged as the clear favorite window managers, so that’s what we concentrate on here. Even if you use a different window manager, it probably works about the same way that Motif does.


Considerably more than you want to know about window managers, toolkits, and X


Technical Stuff If you’re dying to know more about how the X Window system works, strap on your safety belts because we’re going to get a little technical. If you’re dying to know how to use your window manager and couldn’t care less about how it works, skip down to the section “Stupid Window Manager Tricks.” If you’re sticking with us, just don’t say that we didn’t warn you.








Tip Dj vu dj vu


Readers familiar with Microsoft Windows 95 or NT may find the Motif window manager to be strangely familiar. Its windows don’t look all that much like Windows windows, although the mouse and keyboard techniques are extremely similar. That turns out to be no coincidence. Because Hewlett-Packard has a super-duper application environment it sells for both Windows and X, it deliberately made its X package (from which much of Motif is derived) as similar to Windows as possible.

For users who switch back and forth between Windows and Motif (we authors, for example), this capability is a blessing because the mouse moves and keystrokes our fingers have memorized for one system work by and large in the same way in the other. This practically unprecedented level of compatibility exists between UNIX and something else, so we figure that, deep down, it must have been an oversight.











The X Window system divides the work of controlling what’s on-screen among three separate kinds of programs:



X server: Draws pictures on-screen and reads user input from the keyboard and mouse

Window manager: Controls where windows appear on-screen, draws borders around windows, and handles basic window operations, such as moving windows, shrinking windows to an icon (a little box representing that window), and expanding icons to windows

Clients: Programs that do some real work

For any particular screen, there’s one X server, usually (but not always) one window manager, and a bunch of clients. Every client communicates with the server to tell it what to draw and to find out what you did; the server communicates with the window manager when the user asks for a window-management operation, such as changing the size of a window. Although the server, window manager, and clients usually run on the same computer, X Windows enables them to exist on separate machines connected by a network. It is not unusual to have a setup in which the server runs on an X terminal, the window manager runs on a nearby workstation, and the clients are on various machines scattered around the network.

The window manager is usually a regular UNIX program. You can stop one window manager and start another if you decide that you don’t like the way your windows look. Client programs can ask the X server to ask the window manager to do some specialized operations. A terminal program, for example, can ask the window manager to enable a user to change the size of the window only to a size that is a whole number of lines of text. (This kind of communication starts to resemble that in the ancient Roman Empire, in which proconsuls could officially speak only to procurators, who could speak to senators, and so on. Computers are like that.) If no window manager exists, no window-management operations are available.
Writing an X program is a great deal of work. To make life easier for programmers, a programmer can build on toolkits of program code that are already written. MIT sends out X Toolkit (immediately called Xt by the usual lazy typists). This toolkit provides a set of basic window functions that most programs use. Starting with Xt , different people have produced libraries of widgets, or screen elements a program can use. A menu or a file-selection panel is a widget, for example. The Motif widget set is for programs that want to look like Motif. The Athena widgets from MIT’s Project Athena aren’t particularly attractive, but many programs use them because (where have we heard this before?) they’re available for free. You can also find other toolkits for other window systems, including KDE and GNOME.









Linux FVWM: The chameleon of window managers


Because Motif isn’t free, it isn’t included with most Linux and BSD systems. (Nothing prevents you from running Motif under Linux or BSD, but most people aren’t prepared to pay more for a window manager than they paid for the whole operating system and its included software.) Instead, with Linux, you often find the window manager called FVWM.

The origins of the name FVWM are forever lost in the mists of history. The VWM part stands for virtual window manager. The F part is a mystery, though. Fine and feeble are two frequently offered possibilities.

The “virtual” part of this window manager is one of FVWM’s best-loved features. Rather than having just a single desktop, you can have any number of virtual desktops, each with its own independent set of windows open. Because each desktop is the size of the screen, this feature enables you to think of your screen as a porthole looking at part of a much larger screen behind it.

FVWM usually displays a little map of all the virtual desktops at your disposal; Most systems have either four or nine, although theoretically you can have as many or as few as you want. You move around among all your desktops by pressing the Ctrl key and then the arrow key for the direction of the next desktop according to the little map. Is your desktop getting too crowded with windows? No need to close some of them; just pop on over to another desktop. You can have dozens of programs open without getting too crowded; never has slowing your system to a crawl been easier!

FVWM is almost infinitely configurable. You can make it look like practically anything, although its default look is nearly identical to Motif. A version of FVWM known as FVWM95 looks remarkably similar to — you guessed it — Windows 95. (Whether this is A Good Thing is a favorite point of religious arguments among many Linux users.) Not only do its window borders mimic Windows 95, but it also even features a Start button with pull-up menus. FVWM95 is found by default on recent releases of Red Hat Linux (discussed in Chapter 14). Another popular mutation of FVWM is called AfterStep, which looks just like the NeXTStep window system.

FVWM has become enormously popular on free UNIX versions. You can even find it on some large commercial systems.



















Tip How do I start Motif, anyway?


You may think that this question is a simple one to answer, but, because UNIX is involved, it’s not. The short answer is “Run mwm " (the Motif window manager), although that technique is not useful because you have to run mwm at the right time and place.

If you’re lucky, your system manager sets up everything for you automatically. If you’re on an X terminal or a workstation running xdm (the X display manager), X is already running when you sit down and waiting for you to enter your username and password, and Motif starts as soon as you log in.

The next best thing is that you’re at a workstation that is set up to run X after you log in so that X and Motif start automatically when you log in.

Failing that, you have to start X and Motif yourself after you log in to UNIX. The two most common start-up commands are startx and xinit . If you’re not sure which one to use, try them and see what happens. What happens is that your screen goes kerflooie! for a few seconds when it switches from old, dumb, terminal mode to new, cool, graphical X mode; a few windows appear, running xterm (the dumb terminal emulator that runs under X); and Motif starts and draws attractive borders around all the windows.

If none of those things works, we’ve run out of ideas, and you have to ask your local expert how to start X and Motif on your computer or X terminal.











What all this means is that any particular X client uses one of the widget sets to control what that client’s window looks like. A program that uses the Motif toolkit, for example, is a Motif program. Because clients are separate from window managers, however, the Motif window manager (named mwm — the lazy typists strike again) can be running and draw a Motif border around the windows of clients using other toolkits.

Because of the constant danger that GUI systems could begin to make sense to users, UNIX people have learned to obfuscate things by using “Motif” to refer to both the Motif window manager and the Motif toolkit, which are, of course, completely separate entities. When people refer to “Motif,” therefore, they may be referring to the window manager or maybe to the toolkit. Or both. Often it’s difficult to tell. This confusion is all just part of the proud legacy of UNIX evolution.

One school of thought says that we all would be better off if X Windows had picked a window style and stuck with it so that we would have a single window manager and a single set of widgets — as every other window system does — although it’s much too late now for that.

/ 213