Chapter 3: Working with the Desktop

壹. Logging in to Red Hat Linux

Because Red Hat Linux was created as a multiuser computer system, even if you are the only person using the computer, you start by logging in. Logging in identifies you as a particular user. With that identity, Red Hat Linux can start up your configuration and give you appropriate permissions to files and programs.

1. The text-based prompt should look similar to this:

Red Hat Linux release 7.2
Kernel 2.4.7-2 on an i686

localhost login:

2. The X Window System graphical user interface (GUI).

Figure 3-1 is an example of the login window you see if you are using the Gnome desktop environment.


Figure 3-1: A graphical login can access the Red Hat Linux GUI.

-You can simply log in. Or you can use these buttons as follows:

  Note 

The failsafe session(安全模式) is used primarily to correct problems when, for some reason, your desktop session won't start properly. For example, graphics settings may be wrong, resulting in a garbled screen. The failsafe session simply opens a shell window so you can type commands to correct the problem before you log in again. When you are done with a failsafe session, type exit to be allowed to log in again.

 

3. The login session

As you log in, Red Hat Linux starts up a user environment that is unique to your user account. Various attributes are set that remain active during your login session until they are changed. Some of the features that make up your user environment are:

  Note 

Configuration files usually begin with a dot (.), so they do not appear by default when you list the contents of the directory (type ls -a to see dot files).

 

貳. 關於X-Window

. 簡介
-X-Window 系統提供 UNIX 標準的圖形操作它是在 1984 年由麻省理工資訊科學系與迪吉多公司合作開發的一個專案計畫,其目是要發展一個兼具可移植性與網路通透性的視窗系統。

-該專案計畫首度發表的是第十版的視窗系統 (X10),到了 1987 年發表了第十一版 (X11),,到了 1994 年發表了 X11R6,也就是目前 UNIX 系統上通行的版本。而原本負責此專案計畫的成員,也在 1996 底組成了一個稱為 X Consortium 的組織,持續 X11R6 的開發與維護,而其最新的改進版是 X11R6.5。

-X-Window(Not 『X-Windows』)不同於Micrsoft Windows的是,Micrsoft Windows是一個『作業系統』,X-Window則是UNIX作業系統中的一個『提供圖形作業環境的系統』,

-X-Window 系統採取的是 Server/Client 的模型而運作

- Server 指的是 X Server, 它通常掌管一個完整的 Display。根據定義,一個傳統的 Display 包含一個顯示器、一個鍵盤、及一個滑鼠,或者還有其他選擇性的輸出入裝置,換句話說,它就是一個完整的圖型桌面裝置。

- Client 指的是在此 Display 中執行的所有 X Window 應用程式,它們需要在螢幕上繪圖、需要接收滑鼠、鍵盤等輸入 .... 等,都必須向 X Server 發出請求,由 X Server 代為完成。

- X Server 與 Client 之間的溝通協定就稱之為 X 協定。此 X 協定不僅可用於本機的 Display (亦即 X Server 與 Client 都在同一部機器上執行),它更具備了網路的通透性,也就是 X Server 與 Client 可以在不同機器上執行,例如將遠端的 Client 視窗顯示到本地的 X Server 上,而本地的使用者在使用時就和操作本機執行的 Client 一樣。

『讓A機器上執行程式所顯現的圖形,顯示在B機器的螢幕上』,對Microsoft Windows環境而言是難上加難,可是對於X-Window來說,卻是再自然不過的了,因為Client/Server本來就是X-Window的特色。

-由 X Server 掌控的 Display 只是圖形介面的底層平台,不是我們平常所接觸到的桌面環境。我們所用的桌面環境是由「視窗管理程式 (Window Manager)」所提供,它擁有方便的功能表選單、啟動應用程式的按扭圖示、可以幫我們放底圖、及管理桌面上所有的視窗的功能,「視窗管理程式」在 X Server 的眼中,是一個 X Client。 我們可以依自己的喜好挑選視窗管理程式來用。常見的KDE 或 Gnome桌面環境系統,都有內建視窗管理程式,可以讓我們的桌面更加好用。

-Xlib 函式庫簡介: X 應用程式 (Client) 與 X Server 之間的溝通管道,就是實作 X 協定的 X-Window 底層函式庫: Xlib。Xlib 在 X Window 中的地位,就好像系統library 在整個作業系統中的地位一樣。進一步的類比,X Server 的角色就如同作業系統的核心,系統library 提供了系統核心系統呼叫的窗口,同樣的 Xlib 可以直接與 X Server 連繫傳送訊息。若要撰寫 X-Window 的應用程式,則最底層可用的函式庫就是 Xlib。

二. X-Window in Linux

-在 GNU/Linux、FreeBSD 等 x86 平台的自由 UNIX 作業系統中,其 X-Window 系統是來自 XFree86(其中『86』指的是Intel x86) 計畫,該計畫的主要目的是提供一個免費、自由的 X-Window 系統給 x86 個人電腦上的 UNIX 使用。

- XFree86-4.0.X 系列,除了遵循 X11R6.4 的標準以外,同時更進一步地開發了 Unicode 的支援、TrueType 字型支援、模組化顯示卡驅動程式、高速繪圖介面、並逐步修正過去 X Consortium 所發表的程式碼中的錯誤。可以這麼說,XFree86-4.0.X 系列比起過去的版本有著相當長足的進步。而這些改進,未來也許會逐步出現在 X Consortium 新版的 X11R6 中。

-Linux中的X-Window,我們稱他為XFREE86,就是X-Windows相關的軟體,如果你在安裝過程中選擇了他們,你的X-Window即已安裝完成。不過這不代表你的X-Window一定可以用, 若不能使用,必須設定你的X-Windows環境。(Configure X-Window)

 

三.  啟動 X Window, 和使用 GNOME 或 KDE 桌面環境

Linux uses the X Window System (also referred to as X11 or just X) as the framework for its graphical desktop. On top of this framework, Red Hat Linux lets you choose either (or both) of two powerful desktop environments: GNOME and KDE.

This chapter describes how to get your X environment working, start up the desktop, and use the GNOME and KDE desktop environments.

Starting the X Desktop

There are several different ways you can start your desktop in Red Hat Linux. If Red Hat Linux starts up and you see a graphical login screen, you can just log in and your desktop environment should appear. If Red Hat Linux starts up to a simple text-based login prompt, you can have the desktop environment start after you log in (either manually or automatically). Each of these methods is described in this section.

The X Window System GUI (or X GUI) can be started in several different ways, including:

Each of these methods results in the startup of the X GUI and either the GNOME or KDE desktop environment. Along with the GNOME desktop environment, the sawfish window manager (or possibly some other window manager) starts up in order to provide the look-and-feel of the desktop.

  Tip 

If your X screen ever gets garbled to the point where you don’t know how to exit, or if you want to go to a command-line interface, you can do either by using control keys. From the X GUI, press Ctrl+Alt+F2. You will see a text login. After you log in, you can look for the X process (ps ax | less) and kill it (kill pid, where pid is the X process). Or you can return to the GUI by pressing Ctrl+Alt+F7. These extra screens, referred to as virtual terminals, can be accessed using any function keys from Ctrl+Alt+F1 to Ctrl+Alt+F7.

1. Starting the GUI at boot time

The graphical login screen is started by the xdm command (which stands for X Display Manager). The xdm process manages both logging in and starting the GUI for your console monitor, as well as graphical logins from other computers and X terminals.

Normally, you start xdm by setting the system’s default run state to 5. You can determine your system's default run state by checking the /etc/inittab file for an entry that looks similar to the following:

id:5:initdefault:

If the initdefault state is 3, the system boots to a text-based login prompt. At the bottom of that file, you will see that the xdm command is run in system state 5. (Instead of xdm, a GNOME version of xdm called prefdm or gem may run. Either command results in the same functions as xdm.)

 

2. Starting the GUI yourself

If you log in to a nongraphical interface, you can start your X GUI at any time using the startx command. The startx command is a shell script that reads your X configuration files, and starts the xinit command (which starts the X server). To run the startx command, simply type the following:

$ startx
  Tip 

If startx fails with a message "Server is already active," it may be that a lock file was not removed the last time X ran. Assuming you are using display 0 (which is the default), type rm /tmp/.X0-lock.

If you don’t create your own configuration files, startx will read several preset configuration files instead. Just as with xdm, by default you will see the GNOME desktop environment and the sawfish window manager, and possibly some clients (such as the File Manager and a Help Browser).

To override the default behavior of startx, you need to create a $HOME/.xinitrc file. The .xinitrc file can start up some client processes and run the window manager you choose.

 

3. Starting the GUI at login time

If you want to be able to use the X GUI when other users on your system choose not to, set up your user account to start the GUI when you log in. You do this by adding a startx command to one of your personal startup files. One place you can add the startx command is to your $HOME/.bash_profile file (assuming you are using the bash shell as your login shell).

exec startx

The default window manager will start immediately after you log in. Then, when you exit the window manager later, you are logged out and returned to the login prompt

 

Using the GNOME Desktop Environment

GNOME (pronounced guh-nome) provides the desktop environment that you get by default when you install Red Hat Linux. This desktop environment provides the software that is between your X Window System framework and the look-and-feel provided by the window manager.

GNOME is not a window manager, so it must be used with a window manager to provide such things as window borders and window controls. Currently, sawfish is the default window manager with GNOME. You can, however, use other window managers with GNOME, including:

This section describes the GNOME desktop environment and ways of using it. If your Red Hat Linux system is configured to use a GUI by default, you simply need to log in from the graphical login screen. Otherwise, type startx from a shell prompt after you log in. In either case, you should see the GNOME desktop environment similar to that shown in Figure 3-2.


Figure 3-2: In the GNOME desktop environment, you can manage applications from the panel.

 

Using the KDE Desktop Environment

The KDE desktop was developed to provide an interface to Linux and other UNIX systems that could compete with MacOS or Microsoft Windows operating systems for ease of use. Integrated within KDE are tools for managing files, windows, multiple desktops, and applications.

Starting with KDE

You can select the KDE desktop from the login screen (provided that both GNOME and KDE are installed). Choose Session ® KDE. Then, type your login name and password, as prompted. The KDE desktop should appear, as shown in Figure 3-3.


Figure 3-3: Manage files and applications graphically with the KDE desktop.
  Note 

If you are currently using GNOME and want to switch to KDE as your desktop environment, type switchdesk from your GNOME desktop. The switchdesk window that appears will let you change to KDE as the default desktop environment. If by chance the GUI is still GNOME when you log in again, try restarting X as root user by typing the following command line: init 3 ; init 5