歡迎您光臨本站 註冊首頁

一篇很好的Linux精華翻譯貼

←手機掃碼閱讀     火星人 @ 2014-03-23 , reply:0

Appendix H. Tips for New Linux Users
這份安裝指南假設用戶至少具有對Linux技術與術語有基本的了解。在該部分,我們提供了一些可能對Linux新手有幫助的Tips。鑒於這些tips僅用於安裝與設置NVIDIA驅動時闡明與幫助用戶,它並不能被當作是一份Linux操作系統的使用及管理教程。不像其他一些桌面操作系統,在Linux上你很容易就會犯下對系統的不可挽回的錯誤。如果你對Linux的使用並不熟悉,我們強烈建議你在行動前找一份與你的Linux發行版相關的教程。

The command prompt-命令提示符
儘管最新的Linux發行版都帶有全新的桌面界面,很多Linux中的任務仍然需要在命令提示符中完成。如果你對Windows操作系統比較熟悉,Linux中的命令提示符與Windows中的命令提示符很相似,儘管語法和使用稍有些不同。該部分中的所有命令都是在命令提示符下執行的。某些系統被設置成啟動進入控制台模式,此時用戶以命令提示符形式登錄。另外的系統則設置成啟動進入X windos系統,此時用戶必須打開一個終端或者一個控制台窗口以得到一個命令提示符。這項工作一般可以通過在桌面菜單中搜索terminal或者console來完成。鑒於命令提示符是可以自定義的,基本的命令提示符一般由一串包含信息的短字元串、#,$,%三個字元之一以及一個游標(通常是在閃動的),用於指示用戶的輸入將被顯示的位置。

Navigating the directory structure-遊歷目錄結構
Linux具有一個分層的目錄結構。在目錄結構中的任意位置,ls命令將列出當前目錄的內容。file命令將顯示某目錄中的文件類型。例如:

% file filename將顯示文件filename的文件類型。更改目錄由cd命令完成。

% cd dirname將切換當前工作目錄到目錄dirname。在目錄結構中的任意位置執行pwd將顯示當前工作目錄的目錄名。Linux中有兩個特殊的目錄名,.和..,前者代表當前工作目錄,後者代表當前工作目錄的父目錄。對於任何需要以文件名或者目錄名作為參數的命令,你可以給出對象的絕對路徑或者相對路徑。絕對路徑以「/」開頭,代表目錄結構的頂端或者根部。相對路徑以當前工作目錄中的某個目錄開始。相對路徑可能以.或者..開始。路徑的組成功元素以「/」隔開。例如,如果當前的工作目錄是/home/yegle,用戶希望切換到/usr/local目錄中去,他可以任選以下兩個命令中的一個來做到:

% cd /usr/local
或者
% cd ../../usr/local

File permissions and ownership-文件許可權及所有權
所有文件及文件夾都有與之相關的文件許可權及所有權。這可以有效地防止非管理員用戶對系統的無意(或惡意)損壞。可以通過在ls命令后加-l選項來了解一個文件或者目錄的許可權及所有權。例如:

% ls -l

drwxr-xr-x 2 yegle users 4096 Feb 8 09:32 bin
drwxrwxrwx 10 yegle users 4096 Feb 10 12:04 pub
-rw-r--r-- 1 yegle users 45 Feb 4 03:55 testfile
-rwx------ 1 yegle users 93 Feb 5 06:20 myprogram
-rw-rw-rw- 1 yegle users 112 Feb 5 06:20 README

輸出結果中,第一部分第一列字元給出了文件類型,其中「d「表示一個目錄,」-「表示一個正常文件。接下來的9列詳細給出了文件(夾)的許可權(詳見下文)。第二部分給出了與該文件(夾)相關聯的文件數,第三部分給出了文件(夾)的擁有者,第四部分給出了該文件(夾)相關的用戶組,第五部分給出了文件(夾)的位元組數,第六、七、八部分給出了文件(夾)的最後修改時間,第九部分是文件(夾)的名稱。

如前所述,第一部分的后九列給出了文件(夾)的許可權。這幾列被分為3組,第一組給出了文件擁有者(這裡是yegle)的許可權,第二組給出了與該文件(夾)相關的用戶組的許可權,第三組給出了其餘用戶的許可權。r,w,x分別代表讀、寫、執行許可權。例如,用戶yegle有對testfile的讀、寫許可權,在users用戶組中的用戶只有讀許可權,其餘用戶同樣只有讀許可權。然而,對文件myprogram,用戶yegle有讀、寫、執行許可權(假設myprogram是一個可被執行的程序),同時用戶組users和其餘的用戶沒有任何許可權(例如文件所有者不想任何人執行他的程序)。文件的許可權、所有權和與之相關的用戶組可以分別通過命令chmod,chown和chgrp來修改。如果一個擁有適當許可權的用戶想把某README文檔的用戶/用戶組從yegle/users轉到joe/admin,他需要以下幾個步驟:

# chown joe README# chgrp admin READMEThe syntax for chmod is slightly more complicated and has several variations. The most concise way of setting the permissions for a single element uses a triplet of numbers, one for each of user, group and world. The value for each number in the triplet corresponds to a combination of read, write and execute permissions. Execute only is represented as 1, write only is represented as 2, and read only is represented as 4. Combinations of these permissions are represented as sums of the individual permissions. Read and execute is represented as 5, where as read, write and execute is represented as 7. No permissions is represented as 0. Thus, to give the owner read, write and execute permissions, the group read and execute permissions and the world no permissions, a user would do as follows:

% chmod 750 myprogramThe shell
The shell provides an interface between the user and the operating system. It is the job of the shell to interpret the input that the user gives at the command prompt and call upon the system to do something in response. There are several different shells available, each with somewhat different syntax and capabilities. The two most common flavors of shells used on Linux stem from the Bourne shell (sh) and the C-shell (csh) Different users have preferences and biases towards one shell or the other, and some certainly make it easier (or at least more intuitive) to do some things than others. You can determine your current shell by printing the value of the SHELL environment variable from the command prompt with

% echo $SHELLYou can start a new shell simply by entering the name of the shell from the command prompt:

% cshor

% shand you can run a program from within a specific shell by preceding the name of the executable with the name of the shell in which it will be run:

% sh myprogramThe user's default shell at login is determined by whoever set up his account. While there are many syntactic differences between shells, perhaps the one that is encountered most frequently is the way in which environment variables are set.

Setting environment variables
Every session has associated with it environment variables, which consist of name/value pairs and control the way in which the shell and programs run from the shell behave. An example of an environment variable is the PATH variable, which tells the shell which directories to search when trying to locate an executable file that the user has entered at the command line. If you are certain that a command exists, but the shell complains that it cannot be found when you try to execute it, there is likely a problem with the PATH variable. Environment variables are set differently depending on the shell being used. For the Bourne shell (sh), it is done as:

% export MYVARIABLE="avalue"for the C-shell, it is done as:

% setenv MYVARIABLE "avalue"In both cases the quotation marks are only necessary if the value contains spaces. The echo command can be used to examine the value of an environment variable:

% echo $MYVARIABLECommands to set environment variables can also include references to other environment variables (prepended with the "$" character), including themselves. In order to add the path /usr/local/bin to the beginning of the search path, and the current directory . to the end of the search path, a user would enter

% export PATH=/usr/local/bin:$PATH:.in the Bourne shell, and

% setenv PATH /usr/local/bin:${PATH}:.in C-shell. Note the curly braces are required to protect the variable name in C-shell.

Editing text files
There are several text editors available for the Linux operating system. Some of these editors require the X window system, while others are designed to operate in a console or terminal. It is generally a good thing to be competent with a terminal-based text editor, as there are times when the files necessary for X to run are the ones that must be edited. Three popular editors are vi, pico and emacs, each of which can be started from the command line, optionally supplying the name of a file to be edited. vi is arguably the most ubiquitous as well as the least intuitive of the three. pico is relatively straightforward for a new user, though not as often installed on systems. If you don't have pico, you may have a similar editor called nano. emacs is highly extensible and fairly widely available, but can be somewhat unwieldy in a non-X environment. The newer versions each come with online help, and offline help can be found in the manual and info pages for each (see the section on Linux Manual and Info pages). Many programs use the EDITOR environment variable to determine which text editor to start when editing is required.

Root user
Upon installation, almost all distributions set up the default administrative user with the username root. There are many things on the system that only root (or a similarly privileged user) can do, one of which is installing the NVIDIA Linux Driver. We must emphasize that assuming the identity of root is inherently risky and as root it is relatively easy to corrupt your system or otherwise render it unusable. There are three ways to become root. You may log in as root as you would any other user, you may use the switch user command (su) at the command prompt, or, on some systems, use the sudo utility, which allows users to run programs as root while keeping a log of their actions. This last method is useful in case a user inadvertently causes damage to the system and cannot remember what he has done (or prefers not to admit what he has done). It is generally a good practice to remain root only as long as is necessary to accomplish the task requiring root privileges (another useful feature of the sudo utility).

Booting to a different runlevel
Runlevels in Linux dictate which services are started and stopped automatically when the system boots or shuts down. The runlevels typically range from 0 to 6, with runlevel 5 typically starting the X window system as part of the services (runlevel 0 is actually a system halt, and 6 is a system reboot). It is good practice to install the NVIDIA Linux Driver while X is not running, and it is a good idea to prevent X from starting on reboot in case there are problems with the installation (otherwise you may find yourself with a broken system that automatically tries to start X, but then hangs during the startup, preventing you from doing the repairs necessary to fix X). Depending on your network setup, runlevels 1, 2 or 3 should be sufficient for installing the Driver. Level 3 typically includes networking services, so if utilities used by the system during installation depend on a remote filesystem, Levels 1 and 2 will be insufficient. If your system typically boots to a console with a command prompt, you should not need to change anything. If your system typically boots to the X window system with a graphical login and desktop, you must both exit X and change your default runlevel.

On most distributions, the default runlevel is stored in the file /etc/inittab, although you may have to consult the guide for your own distribution. The line that indicates the default runlevel appears as

id:n:initdefault:or similar, where n indicates the number of the runlevel. /etc/inittab must be edited as root. Please read the sections on editing files and root user if you are unfamiliar with this concept. Also, it is recommended that you create a copy of the file prior to editing it, particularly if you are new to Linux text editors, in case you accidentally corrupt the file:

# cp /etc/inittab /etc/inittab.originalThe line should be edited such that an appropriate runlevel is the default (1, 2, or 3 on most systems):

id:3:initdefault:After saving the changes, exit X. After the Driver installation is complete, you may revert the default runlevel to its original state, either by editing the /etc/inittab again or by moving your backup copy back to its original name.

Different distributions provide different ways to exit X. On many systems, the init utility will change the current runlevel. This can be used to change to a runlevel in which X is not running.

# init 3There are other methods by which to exit X. Please consult your distribution.

Linux Manual and Info pages
System manual or info pages are usually installed during installation. These pages are typically up-to-date and generally contain a comprehensive listing of the use of programs and utilities on the system. Also, many programs include the --help option, which usually prints a list of common options for that program. To view the manual page for a command, enter

% man commandnameat the command prompt, where commandname refers to the command in which you are interested. Similarly, entering

% info commandnamewill bring up the info page for the command. Depending on the application, one or the other may be more up-to-date. The interface for the info system is interactive and navigable. If you are unable to locate the man page for the command you are interested in, you may need to add additional elements to your MANPATH environment variable. See the section on environment variables.

[火星人 ] 一篇很好的Linux精華翻譯貼已經有221次圍觀

http://coctec.com/docs/linux/show-post-122040.html