Complete Handbook/Configuring the system
- 1 File system information
- 2 System logging
- 3 System information
- 4 Networking information
- 5 Various configuration settings
- 6 References
File system information
The fstab file
fstab stands for file system table; when you would take a look at a fully configured /etc/fstab file you can easily see why:
/dev/sda8 / ext3 defaults,noatime 0 0 /dev/sda5 none swap sw 0 0 /dev/sda6 /boot ext2 noauto,noatime 0 0 /dev/sda7 /home ext3 defaults,noatime,noexec 0 0 /dev/cdroms/cdrom0 /media/cdrom auto defaults,user,noauto 0 0
Each line declares what storage location (first field) is mounted at a certain location (second field) using a file system (third field) and mounted with one or more options (fourth field). The last two numbers are not that actively used anymore so you can safely set them to 0 0.
It is vital that your /etc/fstab file is a reflection of your environment. By default, Gentoo offers an almost empty /etc/fstab file with illegal storage locations (such as /dev/BOOT and /dev/ROOT). Any user should change the file, otherwise the system might not boot.
The fstab file is used during the system boot procedure to find out what file systems should be mounted, but also during regular system operation. For instance, when you insert a CD in your CD-ROM player, Linux ought to know where it should mount the CD so that you (and perhaps other users) can reach it.
The mount options which you can place in the fourth field in /etc/fstab are well documented in the mount manual page:
Each set of mount options is documented in a section pertaining to the file system used (for instance, ext2, reiserfs, ...). Some of them are available to all file systems, such as
noauto (automatically mount file system or not).
Special file systems
Some lines in the /etc/fstab file have a none as the storage location. Such file systems are pseudo file systems and do not require any storage on the disk.
- The proc file system represents kernel information (like statistics, hardware settings, process information, memory data, ...) as regular files on the file system. You can read from those files to obtain the information you need, but these files are never actually written to disk. Every time you read them, the information is recalculated.
- The tmpfs file system is storage located entirely in memory. Although it is extremely fast, it is also volatile meaning that it loses its content when you reboot the system. The tmpfs file system is often used for temporary file storage (hence the name), but in the previously given /etc/fstab example it serves as a storage point for certain applications who want to share memory without using the shared memory functionality offered by the C library.
- The sysfs file system (not shown in the example as Gentoo mounts /sys automatically when it is present) is the successor of the proc file system. It servers the same purpose, but is restructured so it scales well in larger environments.
Don't forget to edit /etc/fstab to suit your environment. You can use nano to open the file:
nano -w /etc/fstab
Purpose of logging
The system logger is an important daemon on the system. A daemon is a tool that runs in the background; you can't work with it interactively.
The job of the system logger is to obtain information from various processes (and in certain configurations even from remote processes) like logon events, web server requests, security events, kernel messages, ... and write them down in separate files: log files.
Such log files can then be used to resolve issues on the machine (hardware errors are usually quite verbose), generate usage statistics (for instance for web servers), backtrack logon events (for security purposes), etc.
Installing a system logger
Gentoo provides various system loggers, each of them with their own pros and cons: metalog, newsyslog, rsyslog, socklog, sysklogd, and syslog-ng. Which one you choose is up to you, but it is quite important that you pick one: if you do not install a system logger, all events will be displayed on your terminal, cluttering up your screen instead of nicely archiving the events in files.
emerge --ask <systemlogger>
Next you'll need to add the system logger of your choice to the default run level. First find out how the init script is called:
Then, add it to the default runlevel:
rc-update add <initscript> default
With the passwd tool you can set or change any user account password. At first, you need to set the root user password. Run passwd and enter the new password. The tool will ask you to confirm the password by reentering it after which the password is updated.
You might want to verify that your keyboard settings are correct before you enter the root password. If the keyboard settings deviate a bit from what you expect them to be, your root password might actually differ from the one you thought you have entered. As the passwd tool does not echo the characters on screen, you can not verify the password by just looking at it.
On most Gentoo installations, the password itself will be stored in a hashed format in /etc/shadow which is only readable by the root user. Hashed means that the password itself is not shown, but a mathematical result based on the password. A hash gives a theoretically unique value based on certain input (here: the password) but from which you can not revert (i.e. you can not use the hash to obtain the password).
The /etc/passwd file, which contains user account information, is readable by any user. Note though that this file does not always contain your user account information - larger networks will probably store this information on a central server (for instance an LDAP server). The system will look for account information according to the passwd field in /etc/nsswitch.conf.
Next, it is heavily recommended to create a user account for daily tasks. The root user is all-powerful; any mistyped command can severely damage your system. Running your applications as the root user also exposes you to security breaches - although not many Linux viruses exist, the damage that a virus can do depends on the privileges it obtains, and it obtains the privileges from the tool whose flaw it has exploited.
To create a user, use useradd and pass on the
-m option so that the user's home directory (/home/username for the username user) is created. Also add the groups to which you want to make the user part of:
useradd -m -g users -G wheel,audio,cdrom,games,users john
Most groups are self-explanatory, but the wheel group might need a small introduction.
The wheel group contains all users who can run su to switch from one user to another (including the root user). Only put trusted users in this group. A better alternative to the wheel access (since it still requires the user to know the passwords of the accounts it wants to switch to) is to use sudo of which an excellent guide exists.
Gentoo provides several tools for managing your network connections, see Network manager.
Managing network with dhcpcd
The easiest of them to use is dhcpcd. It has perfect integration for wpa_supplicant and automatically switches between wired and wireless connections.
Install dhcpcd, add it to the default runlevel and start it:
emerge --ask net-misc/dhcpcd
rc-update add dhcpcd default
All its configuration goes into /etc/dhcpcd.conf but for most installations nothing needs to be done there. Though man 5 dhcpcd.conf will be helpful in case of advanced configuration demand.
emerge -1 --ask net-wireless/wpa_supplicant
complete its conf.d file with the
wpa_supplicant_args="-B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"
and run it as a service:
rc-update add wpa_supplicant default
Static IP address
In case the network interface card should be configured with a static IP address, add their data to the configuration file as shown for the following example.
interface eth0 static ip_address=192.168.0.10/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1
The hosts file
The /etc/hosts file is a small table the system uses to make immediate translations between hostnames and IP addresses. This file should at least contain one line:
All other lines should be set under that line using the following syntax:
<ip address> <fully qualified hostname> <aliases>
For instance, if you want to assign the host name
gentoobox to the eth0 interface address (for instance, 192.168.0.2):
If you use a domain name for your network (such as
boxes, but it can also be a real reserved domain name like company.com), you should set it like so:
192.168.0.2 gentoobox.boxes gentoobox
Next to the host names assigned to your interfaces, you can also add in the IP address and hostname information for the other hosts on your system if they aren't known to the DNS servers you've specified (in /etc/resolv.conf, perhaps automatically with DHCP).
Various configuration settings
The /etc/rc.conf file
The /etc/rc.conf file contains system-wide settings for the entire system. You will find lots of variables already defined in the file, accompanied with lots of documentation.
The first variable you'll see is the UNICODE variable. Unicode (also known as UTF-8) is the new standard for character encoding. Character encoding tells the system what sequence of bits resembles what character. Well-known encodings are ASCII, ISO-8859-1, etc. The UTF-8 or Unicode encoding is important because it is able to provide encodings for every possible language (including special characters like ¬ but also Chinese characters, etc.).
If you are interested in using Unicode on your system, please read the UTF-8 guide.
Another variable of importance is DISPLAYMANAGER. A display manager is a tool which shows a graphical logon screen after having booted your system. Most display managers even allow you to automatically log on as a specific user. If you want to use a display manager, you need to install one, add the xdm init script to the default runlevel and make sure that this variable points to the display manager of your choice.
Together with the DISPLAYMANAGER variable you'll find the XSESSION one. This tells the display manager what graphical environment it should load by default if the user didn't specify one explicitly. Well-known graphical environments are KDE, GNOME, XFCE, fluxbox, ... For specific instructions on how this variable influences the graphical logon process please read the comments in the rc.conf file.
Select keyboard language
If you aren't using a US Qwerty keyboard, you'll need to edit the /etc/conf.d/keymaps file to tell the Gentoo system what keyboard layout it should use.
- Presumed that most computers nowadays are behind a router or access point providing DHCP