分類和使用 Subodh Soni(subodh@in.ibm.com) IBM 軟體工程師 2001 年 12 月
本文說明了 Linux 系統的配置文件,在多用戶、多任務環境中,配置文件控制用戶許可權、系統應用程序、守護進程、服務和其它管理任務。這些任務包括管理用戶帳號、分配磁碟配額、管理電子郵件和新聞組,以及配置內核參數。本文還根據配置文件的使用和其所影響的服務的情況對目前 Red Hat Linux 系統中的配置文件進行了分類。 介紹 每個 Linux 程序都是一個可執行文件,它含有操作碼列表,CPU 將執行這些操作碼來完成特定的操作。例如,ls 命令是由 /bin/ls 文件提供的,該文件含有機器指令的列表,在屏幕上顯示當前目錄中文件的列表時需要使用這些機器指令。幾乎每個程序的行為都可以通過修改其配置文件來按照您的偏好或需要去定製。
Linux 中有沒有一個標準的配置文件格式? 一句話,沒有。不熟悉 Linux 的用戶(一定)會感到沮喪,因為每個配置文件看起來都象是一個要迎接的新挑戰。在 Linux 中,每個程序員都可以自由選擇他或她喜歡的配置文件格式。可以選擇的格式很多,從 /etc/shells 文件(它包含被一個換行符分開的 shell 的列表),到 Apache 的複雜的 /etc/httpd.conf 文件。
/etc/lynx.cfg 中的代理伺服器設置 .h1 proxy .h2 HTTP_PROXY .h2 HTTPS_PROXY .h2 FTP_PROXY .h2 GOPHER_PROXY .h2 NEWS_PROXY .h2 NNTP_PROXY # Lynx version 2.2 and beyond supports the use of proxy servers that can act as # firewall gateways and caching servers. They are preferable to the older # gateway servers. Each protocol used by Lynx can be mapped separately using # PROTOCOL_proxy environment variables (see Lynx Users Guide). If you have # not set them externally, you can set them at run time via this configuration file. # They will not override external settings. The no_proxy variable can be used # to inhibit proxying to selected regions of the Web (see below). Note that on # VMS these proxy variables are set as process logicals rather than symbols, to # preserve lowercasing, and will outlive the Lynx image. # .ex 15 http_proxy:http://proxy3.in.ibm.com:80/ ftp_proxy:http://proxy3.in.ibm.com:80/ #http_proxy:http://penguin.in.ibm.com:8080 #ftp_proxy:http://penguin.in.ibm.com:8080/
.h2 NO_PROXY # The no_proxy variable can be a comma-separated list of strings defining # no-proxy zones in the DNS domain name space. If a tail substring of the # domain-path for a host matches one of these strings, transactions with that # node will not be proxied. .ex no_proxy:demiurge.in.ibm.com, demiurge
內核 更改內核中的配置文件會立即影響到系統。例如,更改 passwd 文件以增加用戶將立即使該用戶變為可用。而且任何 Linux 系統的 /proc/sys 目錄中都有一些內核可調參數。只有超級用戶可以得到對所有這些文件的寫訪問權力;其它用戶只有隻讀訪問權力。此目錄中文件的分類的方式和 Linux 內核源代碼的分類方式一樣。此目錄中的每個文件都代表一個內核數據結構,這些數據結構可以被動態地修改,從而改變系統性能。
守護進程和系統程序 守護進程是永遠運行在後台的程序,它默默地執行自己的任務。常見的守護進程有 in.ftpd(ftp 伺服器守護進程)、in.telnetd(telnet 伺服器守護進程)和 syslogd(系統日誌記錄守護進程)。有些守護進程在運行時會嚴密監視配置文件,在配置文件改變時就會自動重新載入它。但是大多數守護進程並不會自動重新載入配置文件。我們需要以某種方式「告訴」這些守護進程配置文件已經被發生了改變並應該重新載入。可以通過使用服務命令重新啟動服務來達到這個目的(在 Red Hat Linux 系統上)。
例如,如果我們更改了網路配置,就需要發出: service network restart。
注意:這些服務最常見的是 /etc/rc.d/init.d/* 目錄中存在的腳本,在系統被引導時由 init 啟動。所以,您也可以執行如下操作來重新啟動服務: /etc/rc.d/init.d/ start | stop | status start、stop 和 status 是這些腳本接受的輸入值,用來執行操作。
要了解更多信息,請閱讀 Jack Wallen, Jr. 的 Linux configuration files。
在 developerWorks 上還有: Technical FAQ for Linux users What good is a Linux client? Using the xinetd program for system administration
流覽 developerWorks 上的更多 Linux 參考資料。
流覽 developerWorks 上的更多開放源代碼參考資料。
關於作者 Subodh Soni 持有印度 College Surat 大學計算機科學與技術地區工程學的工程學學士學位。他為印度的 IBM Global Services(IBM Software Labs)工作;他還是 IBM Linux Technology Center 的成員之一,在那裡他致力於 Linux RAS(Reliability,Availability and Serviceability(可靠性、可用性和適用性))。他感興趣的其它領域還有操作系統內部、Linux 系統管理和疑難解答。您可以通過 subodh@in.ibm.com 與他聯繫。