Every Linux A program is an executable file , It contains a list of opcodes ,CPU These opcodes are executed to perform specific operations . for example ,ls The order is made by /bin/ls The document provides , This file contains a list of machine instructions , You need to use these machine instructions to display a list of files in the current directory on the screen . Almost every program's behavior can be customized to your preferences or needs by modifying its configuration file .
Linux Is there a standard configuration file format in ？
In a word , No, . Not familiar with Linux Users of （ A certain ） You'll feel depressed , Because every profile looks like a new challenge to meet . stay Linux in , Every programmer is free to choose his or her preferred configuration file format . There are many formats to choose from , from /etc/shells file （ It contains... Separated by a newline character shell A list of ）, To Apache Complicated /etc/httpd.conf file .
What is a system profile ？
The kernel itself can also be seen as a “ Program ”. Why does the kernel need configuration files ？ The kernel needs to know the list of users and groups in the system , And then manage file permissions （ That is, according to the authority to determine a specific user （UNIX_USERS） Whether a file can be opened ）. Be careful , These files are not explicitly read by the program , It is read by a function provided by the system library , And used by the kernel . for example , The program needs someone's （ Encrypted ） Password should not be opened /etc/passwd file . contrary , The program should call the getpw() function . This function is also called a system call . open /etc/passwd The file and the password of the user who is asked to find it later are created by the kernel （ Through the system library ） Decisive .
Unless otherwise specified ,Red Hat Linux Most of the configuration files in the system are in the /etc Directory . Configuration files can be roughly divided into the following categories ：
|/etc/host.conf||Tell the network domain name server how to find the host name .（ Usually /etc/hosts, Then there is the name server ; It can be done by netconf Change it ）|
|/etc/hosts||contain （ In the local network ） A list of known hosts . If the system IP Not dynamically generated , You can use it . For simple hostname resolution （ Point representation ）, In the request DNS or NIS Before network name server ,/etc/hosts.conf You usually tell the parser to look here first .|
|/etc/hosts.allow||see also hosts_access Online help page for . At least by tcpd Read .|
|/etc/hosts.deny||see also hosts_access Online help page for . At least by tcpd Read .|
Boot and login ／ Cancellation
|/etc/issue & /etc/issue.net||These documents are made up of mingetty（ And similar procedures ） Read , Used to send data to the slave terminal （issue） Or through telnet conversation （issue.net） The connected user displays a “welcome” character string . They include several lines of statements Red Hat Version number 、 Name and kernel ID Information about . They are created by rc.local Use .|
|/etc/redhat-release||Include a line statement Red Hat Version number and name information . from rc.local Use .|
|/etc/rc.d/rc|| Typically runs at all run levels , The level is passed as a parameter . for example , To create a graph （Graphics） Pattern （X-Server） Guide the machine , Please run the following command on the command line ：
|/etc/rc.d/rc.local||Informal . It can be downloaded from rc、rc.sysinit or /etc/inittab call .|
|/etc/rc.d/rc.sysinit||Usually the first script at all run levels .|
|/etc/rc.d/rc/rcX.d||from rc Running script （ X Express 1 To 5 Any number between ）. These directories are specific “ Operation level ” The catalog of . When the system starts , It identifies the run level to start , Then invoke all the boot scripts that exist in the specific directory of the runlevel. . for example , When the system starts, it is usually displayed after the boot message “entering run-level 3” The news of ; It means /etc/rc.d/rc3.d/ All initialization scripts in the directory will be called .|
The kernel provides an interface , Used to display some of its data structures , These data structures are important for determining such as the use of interrupts 、 System parameters such as initialized device and memory statistics can be useful . This interface is provided as a stand-alone but virtual file system , be called /proc file system . Many system utilities use values that exist in this file system to display system statistics . for example ,/proc/modules The file enumerates the modules currently loaded in the system .lsmod Command to read this information , And then display it in a format that people can understand . As specified in the table below mtab The file reads the file containing the currently installed file system in the same way /proc/mount file .
|/etc/mtab||This will follow /proc/mount The document changes and keeps changing . let me put it another way , When the file system is installed and uninstalled , Changes are immediately reflected in this file .|
|/etc/fstab|| List the current status of the computer “ Can install ” File system . It's very important , Because the computer will run at boot time
|/etc/mtools.conf||DOS All operations on a file system of type （ Create directory 、 Copy 、 Format and so on ） Configuration of .|
|/etc/group|| Contains a valid group name and the users included in the specified group . If a single user performs multiple tasks , Can exist in multiple groups . for example , If one “ user ” yes “project 1” Members of the engineering team , Also an administrator , So in group His entry in the file would look like this ：
|/etc/nologin||If there is /etc/nologin File exists ,login(1) Will only be allowed root Users access . It will display the contents of this file to other users and deny them login .|
|etc/passwd||see also “man passwd”. It contains some user account information , Include password （ If not by shadow The program has been encrypted ）.|
|/etc/rpmrc||rpm Command configuration . be-all rpm Command line options can be set together in this file , such , When anything rpm When the command runs in the system , All options are global .|
|/etc/securetty||Include device name , from tty Line composition （ One name per line , Not including the front ones /dev/）,root Users are allowed to log in here .|
| Contains encrypted user account password information , It can also include password aging information . The fields included are ：
|/etc/shells||Contains the possible “shell” A list of .|
|/etc/motd||Daily News ; When the administrator wants to Linux Used when all users of the server communicate a message .|
Connected to the Internet
|/etc/gated.conf||gated Configuration of . Can only be gated Used by the daemons .|
|/etc/gated.version||contain gated The version number of the daemons .|
|/etc/gateway||from routed The daemons use the .|
|/etc/networks||List the network names and addresses that can be accessed from the network to which the machine is connected . Using routing commands . Allow network name .|
|/etc/protocols||List the currently available protocols . see also NAG（ Network administrator's Guide ,Network Administrators Guide） And online help pages . C Interface is getprotoent. It must not be changed .|
|/etc/resolv.conf||Request in program “ analysis ” One IP Address tells the kernel which name server to query .|
|/etc/rpc||contain RPC Instructions ／ The rules , These instructions ／ Rules can be found in NFS call 、 Remote file system installation, etc .|
|/etc/exports||File system to export （NFS） And access to it .|
|/etc/services||Convert network service name to port number ／ agreement . from inetd、telnet、tcpdump And some other programs . Somewhat C access routine .|
|/etc/inetd.conf||inetd Configuration file for . see also inetd Online help page . Contains an entry for each network service ,inetd Daemons or other services must be controlled for these network services . Be careful , The service will run , But in /etc/services They were annotated out , In this way, even if these services are running, they will not be available . The format is ：<service_name> <sock_type> <proto> <flags> <user> <server_path> <args>|
|/etc/sendmail.cf||Mail program sendmail Configuration file for . More obscure , It's hard to understand. .|
|/etc/sysconfig/network||Pointed out that NETWORKING=yes or no. At least by rc.sysinit Read .|
|/etc/sysconfig/network-scripts/if*||Red Hat Network configuration script .|
The system command should control the system exclusively , And make it work . All as login（ Complete the console user authentication phase ） or bash（ Provides interaction between users and computers ） Programs like this are system commands . therefore , Documents related to them are also particularly important . In this category are the following files of interest to users and administrators .
|/etc/lilo.conf||Contains the default boot command line parameters for the system , There are also different images used at startup . You are in LILO Press the Tab Key to see the list .|
|/etc/logrotate.conf||maintain /var/log Log files in directory .|
|/etc/identd.conf||identd It's a server , It follows RFC 1413 Document in the specified way TCP/IP Proposed criteria IDENT User identification protocol .identd The operation principle of is to find a specific object TCP/IP Connect and return the user name of the process that owns the connection . As an option , It can also return other information , Not the username . see also identd Online help page .|
|/etc/ld.so.conf||“ Dynamic link program ”（Dynamic Linker） Configuration of .|
|/etc/inittab||In terms of age , This is a UNIX First profile in . At one UNIX The first program to start after the machine is turned on is init, It knows what to start , This is because inittab The existence of . When the run level changes ,init Read inittab, Then control the start of the main process .|
|/etc/termcap||A database , Contains all possible terminal types and the performance of these terminals .|
A daemon is a program that runs in non interactive mode . Generally speaking , The task of the daemons is related to the networking area ： They wait to connect , In order to provide services through the connection .Linux You can use from Web Server to ftp There are many daemons on the server .
|/etc/syslogd.conf||syslogd Configuration files for Daemons .syslogd It's a kind of daemon , It is responsible for recording （ Write to disk ） Messages sent to the system from other programs . This service is especially used by some daemons , There is no other way for these daemons to signal a possible problem or send a message to the user .|
|/etc/httpd.conf||Web The server Apache Configuration file for . This file is usually not available /etc in . It may be in /usr/local/httpd/conf/ or /etc/httpd/conf/ in , But make sure it's located , You also need to check the specific Apache Installation information .|
|/etc/conf.modules or /etc/modules.conf||kerneld Configuration file for . What's interesting is that ,kerneld Not at all “ As a daemon ” kernel . It's actually a way of being responsible when needed “ Fast ” Daemons for loading additional kernel modules .|
stay Linux（ And general UNIX） in , There are countless “ user ” Program . The most common type of user program configuration file is /etc/lynx.cfg. This is the famous text browser lynx Configuration file for . Through this document , You can define a proxy server 、 The character set to use, etc . The following code sample shows lynx.cfg Part of the document , You can change this part of the code Linux Proxy server settings of the system . By default , These settings apply in the respective shell Run in lynx All users of , Unless specified by a user
--cfg = "mylynx.cfg" The default configuration file is reset .
/etc/lynx.cfg Proxy settings in
Changing configuration files
When changing the configuration file , If the program is not controlled by the system administrator or kernel , Make sure to restart the program that used this configuration . Ordinary users usually do not start or stop system programs and programs ／ Or the permissions of the daemons .
Changing the configuration file in the kernel immediately affects the system . for example , change passwd File to add a user will immediately make that user available . And anything Linux Systematic /proc/sys There are some kernel tunable parameters in the directory . Only the superuser can get write access to all of these files ; Other users only have read-only access . How and how the files in this directory are classified Linux Kernel source code is classified in the same way . Each file in this directory represents a kernel data structure , These data structures can be modified dynamically , So as to change the system performance .
Be careful ： Before changing any value of any of these files , You should make sure you have a thorough understanding of the document , To avoid irreparable damage to the system .
/proc/sys/kernel/ Files in directory
|threads-max||The maximum number of tasks that the kernel can run .|
|ctrl-alt-del||If the value is 1, Then pressing these keys in sequence will “ Thoroughly ” Reboot the system .|
|sysrq||If the value is 1,Alt-SysRq Is active .|
|osrelease||Displays the release version number of the operating system|
|ostype||Displays the type of operating system .|
|hostname||Host name of the system .|
|domainname||Network domain , The system is part of the network domain .|
|modprobe||Appoint modprobe Should the required modules be automatically run and loaded at startup .|
Daemons and system programs
Daemons always run in the background , It carries out its mission in silence . Common daemons are in.ftpd（ftp Server daemons ）、in.telnetd（telnet Server daemons ） and syslogd（ System logging Daemons ）. Some daemons monitor configuration files closely at run time , The configuration file is automatically reloaded when it changes . However, most daemons do not automatically reload the configuration file . We need to do it in some way “ tell ” These daemons configuration files have been changed and should be reloaded . You can do this by using the service command to restart the service （ stay Red Hat Linux On the system ）.
for example , If we change the network configuration , It needs to be sent out ：
service network restart .
Be careful ： The most common of these services are /etc/rc.d/init.d/* Scripts that exist in the directory , When the system is booted by init start-up . therefore , You can also restart the service by doing the following ：
/etc/rc.d/init.d/<script-for-the-service> start | stop | status
start、stop and status Is the input value that these scripts accept , Used to perform operations .
Users or system programs read their configuration files every time they start . For all that , please remember , Some system programs are not the same when the computer is turned on , Their behavior depends on the /etc/ Content read in the configuration file in . therefore , The first time a user program starts, it starts from /etc/ The default configuration for reading files that exist in the directory . then , Users can use the rc and .（ spot ） File to customize the program , As shown in the following section .
User profile ：.（ spot ） Document and rc file
We've seen how to easily configure programs . But if someone doesn't like to be in the /etc/ How to configure the program in ？“ Ordinary ” Users cannot simply enter /etc Then change the configuration file ; From a file system perspective , The owner of the configuration file is root user ！ That's why most user programs define two profiles ： The first is “ System ” Grade , be located /etc/; The other belongs to the user “ special ”, It can be found in his or her home directory .
for example , I've installed very useful software on my system wget Utilities ./etc/ There is one of them. /etc/wgetrc file . In my home directory , There is one named .wgetrc The file of , It describes my customized configuration （ Only in me , That is, the user runs wget On command , This configuration file will be loaded ）. Other users are in their own home directory （/home/other） There can be .wgetrc file ; Of course , Only these users are running wget On command , To read this file . let me put it another way ,/etc/wgetrc File for wget Provides “ default ” value , and /home/xxx/.wgetrc The file lists a user's “ Custom items ”. The important thing is that it's just “ General rules ”, This is not always the case . for example , An elephant pine The same procedure , stay /etc/ There are no files in the database , It has only one custom configuration file in the user's home directory , be known as .pinerc. Other programs may only have /etc/ Default profile in , And users may not be allowed “ customized ” These profiles （/etc There are only a few in the catalog config. This is the case ）.
Commonly used rc and .（ spot ） file
|~/.bash_login||Please refer to “man bash”. If ~/.bash_profile non-existent ,bash Will ~/.bash_login As ~/.bash_profile Handle .|
|~/.bash_logout||Please refer to “man bash”. On exit by bash Sign in shell quote .|
|~/.bash_profile||from bash Sign in shell quote /etc/profile Reference after .|
|~/.bash_history||List of previously executed commands .|
|~/.bashrc||Please refer to “man bash”. from bash Non login interactive shell quote （ There are no other documents ）. Unless set BASH_ENV or ENV, Non interactive shell Do not reference any files .|
|~/.emacs||Start time by emac Read .|
|~/.forward||If you include an email address here , So all of them are sent to ~ The owner's email will be forwarded to this email address .|
|~/.fvwmrc ~/.fvwm2rc||fvwm and fvwm2（ Basic X Window Manager ） Configuration file for .|
|~/.hushlogin||Please refer to “man login”. cause “ No prompting ” Sign in （ No email notification 、 Last login information or MOD Information ）.|
|~/.mail.rc||User initialization file for mail program .|
|~/.ncftp/||ncftp Directory of programs ; Include bookmarks 、 journal 、 macro 、 Preferences and tracking information . see also man ncftp.ncftp The purpose of is to establish a standard file transfer protocol for the Internet （Internet standard File Transfer Protocol） Provides a powerful and flexible interface . It is designed to replace the standard software used by the system ftp Program .|
|~/.profile||Please refer to “man bash”. If ~/.bash_profile and ~/.bash_login file does not exist ,bash Will ~/.profile As ~/.bash_profile Handle , And inherited by others Bourn Of shell Use .|
|~/.pinerc||Pine To configure|
|~/.muttrc||Mutt To configure|
|~/.exrc|| This file can be controlled vi Configuration of .
Example ：set ai sm ruler
Writing the above line in this file will cause vi Set auto indent 、 Match bracket 、 Display line numbers and lines - List these options .
|~/.vimrc||Default “Vim” The configuration file . and .exrc equally .|
|~/.gtkrc||GNOME tool kit （GNOME Toolkit）.|
|~/.kderc||KDE To configure .|
|~/.netrc||ftp Default login name and password .|
|~/.rhosts|| from r- Tools （ Such as rsh、rlogin wait ） Use . Because it's easy to impersonate the host , So the security is very low .
|~/.rpmrc||see also “man rpm”. If /etc/rpmrc If it doesn't exist, it's up to you rpm Read .|
|~/.signature||Message text , Will be automatically attached to the end of messages sent from this account .|
|~/.twmrc||twm（ The Window Manager） Configuration file for .|
|~/.xinitrc|| Start time by X Read （ Rather than by xinit Script read ）. It usually starts some programs .
Example ：exec /usr/sbin/startkde
If the above line exists in the file , Then send it from this account startx On command , This line will start “KDE Window Manager ”（KDE Window Manager）.
|~/.xmodmaprc||This file is transferred to xmodmap Program , And it can be named any file （ for example ~/.Xmodmap and ~/.keymap.km）.|
|~/.xserverrc||If xinit You can find the X,xinit The file will be used as X Server running .|
|~/News/Sent-Message-IDs||gnus Default message history file for .|
|~/.Xauthority||from xdm Program read and write , To process permissions . see also X、xdm and xauth Online help page .|
|~/.Xdefaults, ~/.Xdefaults-hostname||Host computer hostname During the start-up of X Application read . If you can't find it -hostname file , Search for .Xdefaults file .|
|~/.Xmodmap||Point to .xmodmaprc;Red Hat There are people who use this name .xinitrc file .|
|~/.Xresources||It's usually delivered to xrdb To load X The name of the file for the resource database , The purpose is to avoid the application needing to read a long .Xdefaults File such a situation .（ Some cases have been used ~/.Xres.）|
|~/mbox||User's old mail .|