UNIX System Administration Handbook - Evi Nemeth [30]
To configure a network interface under FreeBSD, set the variables called hostname, defaultrouter, and ifconfig_if (where if is the name of the interface). The ifconfig_if variable should contain a string of options to be passed to ifconfig for that interface.
For example, these lines
hostname="my.fullyqualified.name"
ifconfig_de0="inet 192.168.1.2 netmask 0xffffff00"
defaultrouter="192.168.1.1"
configure the host with an address of 192.168.1.2 and a default route to 192.168.1.1. To use DHCP to configure the interface, use a line like this:
ifconfig_de0="DHCP"
Here, DHCP will set the hostname (based on the returned IP address), the IP address, and the default route for the interface all at once.
2.5 REBOOTING AND SHUTTING DOWN
UNIX filesystems buffer changes in memory and write them back to disk only sporadically. This scheme makes disk I/O faster, but it also makes the filesystem more susceptible to data loss when the system is rudely halted.
Traditional UNIX machines were very touchy about how they were shut down. Modern systems have become less sensitive, but it is always a good idea to shut down the machine nicely when possible. Improper shutdown can result in anything from subtle, insidious problems to a major catastrophe.
On non-UNIX operating systems, rebooting the operating system is an appropriate first course of treatment for almost any problem. On a UNIX system, it’s better to think first and reboot second. UNIX problems tend to be subtler and more complex, so blindly rebooting is effective in a smaller percentage of cases. UNIX systems also take a long time to boot, and multiple users may be inconvenienced.
You usually need to reboot when you add a new piece of hardware or when existing hardware becomes so confused that it cannot be reset. If you modify a configuration file that’s used only at boot time, you must reboot to make your changes take effect. If the system is so wedged that you cannot log in to make a proper diagnosis of the problem, you obviously have no alternative but to reboot.
Some things can be changed and fixed without rebooting, but whenever you modify a startup script, you should reboot just to make sure that the system will come back up successfully.
Unlike bootstrapping, which can be done in essentially only one way, there are a number of ways to shut down or reboot. They are:
• Turning off the power
• Using the shutdown command
• Using the halt and reboot commands (BSD, Linux)
• Sending init a TERM signal
• Using telinit to change init’s run level (SystemV-ish systems)
• Killing init
Turning off the power
Even on a small UNIX system, turning off the power is not a good way to shut down. You can potentially lose data and leave the system’s files in an inconsistent state.
Some machines (e.g., HPs) have a “soft power switch,” which means that when you press the power button, the machine actually runs some commands to perform a proper shutdown sequence. If you’re not sure whether your machine provides this feature, don’t poke the power button to find out! It’s better to perform the shutdown sequence yourself.
That said, however, powering off is not the end of the world. In the event of a flood or fire, it’s OK to turn off the power if you can’t afford the time to bring machines down gracefully. Old-style machine rooms often had a panic button that turned everything off at once.
shutdown: the genteel way to halt the system
shutdown is the safest, most considerate, and most thorough way to initiate a halt or reboot or to return to single-user mode. Unfortunately, almost every vendor has decided to tamper with its arguments. We discuss the command in general, then provide a table listing the syntax and arguments you will need on each platform.
You can ask shutdown to wait a while before bringing down the system. During the waiting period, shutdown sends messages (a la wall) to logged-in users at progressively shorter intervals, warning them of the impending downtime. By default, the warnings simply say