Notes sur FreeBSD

Using 'vi' as text Editor

vi <filename> .... [ESC] -- edit a file
i .... [ESC] -- insert text before cursor position
A .... [ESC] -- append text to end of current line
x -- delete character under cursor
dd -- delete whole line
:wq .... [ESC] -- save and exit
:q! -- exit without saving
ESC Shift-ZZ -- save and exit
o .... [ESC] -- insert a line after cursor position
dd -- delete the current line
h j k l -- left|down|up|right (preferred)

Network Information

ifconfig

This is the command you use to interactively start and stop network interfaces and to define how they run. You need root access to use this command.

rc.conf

The main system configuration file is /etc/rc.conf. This file is edited by /stand/sysinstall, but it's perfectly OK to edit this by hand. It is in this file that you configure the hostname, IP address for each interface, and so on. Changes you make in here won't take effect until you reboot.
defaultrouter="80.248.72.126"  
hostname="host1.t1.ws.afnog.org"  
ifconfig_ed0="inet 80.248.72.1 netmask 255.255.255.248" 
# On hosts where you don't want sendmail to accept incoming port 25  
# (but you still want daemons to be able to send outgoing mail):  sendmail_flags="-q30m"  

The sendmail flag is not set in this workshop. The full list of options, and their default values, can be found in /etc/defaults/rc.conf - but don't edit this file, edit /etc/rc.conf instead. This makes it easier to upgrade your system to a later version of FreeBSD.

Stopping and Starting the Network

You may be used to something like "/etc/rc.d/init.d/network stop" under Linux. Under FreeBSD this functionality resides in /etc/rc.conf and is parsed at system startup. So, to stop your currently running network first use ifconfig to figure out what interface you wish to stop.

This displays your network interface status. Notice that "sis0" (Fast Ethernet) has an IP address assigned. Not that lo0 as an address as well. This is your loopback device. To bring sis0 down type:

Now to bring it back up just type:

There is quite a bit more to ifconfig and we'll discuss this during the Monday evening FreeBSD session as well, or you can type "man ifconfig" for more information. Review the "rc.conf" section above as well.

Stopping and Starting Services

By default, system services are configured in /etc/rc.conf and are started at system startup. If you need to start and stop one of these services (perhaps you changed the service's configuration file) you should do the following:

or to find a particular running service, like sendmail, try:

You'll get output that includes the process ID number on the left. If you make a change to the process's configuration, or just need to restart the process, you can do the following:

Note, if the service is a third party package, then you can often find configuration files for the service in /usr/local/etc/. In addition you may find shell scripts that can start and stop the service with command line parameters in /usr/local/etc/rc.d. Use these scripts instead, when available, to start and stop a service. Default services are now being placed in /etc/rc.d, so you may need to use one of these scripts to stop/start a service.