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.
-You can simply log in. Or you can use these buttons as follows:
Session - Usually when you log in, your graphical desktop starts up (either Gnome or KDE desktops). Click Session to choose a different desktop (if available) or to select Failsafe. If you can't remember which desktop to use, you can choose Last (to use the desktop you used most recently) or Default (to use the desktop set as your default). You use Failsafe if you want only a shell interface.
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. |
Language - Click Language to select a language other than the last language you used (indicated by the Last button on this menu). (You need additional software packages to use different languages.)
System - If instead of logging in, you want to shut down or restart the computer, click System, and select either Reboot or Halt.
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:
A home directory - The home directory identifies a location on the computer's hard disk where you can save and protect the files that you need. You can organize your files any way you like and assign permissions to those files to prevent or allow access to them by others.
The root user's home directory in Linux is usually /root. Other users typically have home directories in the /home directory. For example, if your user name were johnq, your home directory would probably be /home/johnq.
A shell configuration - There are several shells available for use with Linux. The bash shell (which stands for Bourne Again SHell) is most commonly used with Linux.
Within your home directory are several configuration files that set up properties for your shell login session. These files may identify the path (where programs are located that you can use), contain environment variables and aliases (described later), and define functions that make your work more efficient.
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). |
A graphical configuration - Most GUIs used with Linux are based on the X Window System (often referred to simply as X). While X provides a framework for a GUI that lets you run applications, it enables you to choose from many different desktop environments. For Red Hat Linux, the Gnome and KDE desktop environments are available to provide a interface to the applications, menus, and windows of your GUI.
-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)
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.
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:
At boot-time — After your video card and monitor are properly configured, you may want to have the X GUI start automatically when Red Hat Linux is booted. You can do this by setting your system initialization state to 5. After you log in, you will see the GNOME or KDE desktop environments.
From the shell (or starting it yourself) — If you have logged in to a shell interface, you can start the GUI at any time using the startx command. When you quit from the GUI, you will be back at your shell prompt.
At login time — To start with a text-based login screen, but have the X GUI started after you log in, you can add the startx command to one of your personal startup files (such as $HOME/.bash_profile).
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. |
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.)
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.
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
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:
Enlightenment
Window Maker
Twm
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.
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.
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.
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 |