Scripts versus Configuration Files

Quite a few Linux configuration files are actually scripts, generally written using the bash shell scripting language. Examples include whatever script init calls with the si line in /etc/inittab and SysV startup scripts. (The /etc/inittab file itself is not a bash script, though.) Scripts are typically used to launch programs, such as daemons and system configuration tools—ifconfig, insmod, and so on. Essentially, scripts leverage the power of ordinary text-mode Linux system administration tools, using them automatically during the system boot process or at other times, such as when you manually change the runlevel. Chapter 4 introduces shell scripting with bash. You should consult that chapter if you're unfamiliar with shell scripting but you need to modify a startup script. For more detailed information, consult a book on bash shell scripting, such as Newham and Rosenblatt's Learning the bash Shell (O'Reilly, 1998).

Nonscript configuration files, on the other hand, simply store data that's used by other tools. For instance, the Postfix mail server uses /etc/postfix/main.cf as its configuration file. This file isn't a script, but its syntax resembles variable assignment operations in scripts. This file contains lines like this:

virtual_maps = hash:/etc/postfix/virtual disable_dns_lookups = no

Each configuration file uses its own syntax. For instance, some use equal signs (=) to assign values to variables, but others don't. Some break the file into distinct sections, in which assignments or other operators apply only to specific features of the program. Because the rules for constructing and modifying configuration files vary from one program to another, you should consult the program's documentation, either provided with the program or in a book, third-party web page, or the like, before modifying these programs' configuration files.

Sometimes the line between boot scripts and configuration files is blurry. For instance, most Linux distributions use files in /etc/network, /etc/sysconfig/networking, or a similar location to store variables relevant to network configuration. These files frequently lack the first-line #!/bin/bash identification as scripts, but they're loaded by SysV or other startup scripts in order to assign values to variables that are used in the scripts' network-initialization calls. This practice enables you or the distributions' configuration tools to modify the configuration files without adjusting the sensitive SysV startup scripts.

0 0

Post a comment