Linux hides useful information about your computer all over your system. These resources are one of the reasons Linux is so useful, but learning about these resources can be tough. This section documents some useful files and directories that can make your administration life easier.
System-wide configuration files are kept in /etc. If you need to configure some service or program that affects all users, you want to look here. Generally, the configuration files for a package will bear that package's name.
Configuration files in Linux are usually plain text files, which you can edit with an editor. Before editing any configuration file, you should make a backup so that you can restore settings if you mess up.
In addition to system-wide configuration, individual users can control the behaviour of applications using dotfiles in their home directories. A dotfile is a file or directory that begins with a period (and so is hidden when typing ls but revealed when typing ls -a). Unless you want to change an application's configuration for every user on the system, you often want to change the appropriate dotfiles in your home directory instead.
Functionality such as printing, mail delivery, and the firewall are called services. Services on your system are controlled by daemons -- special programs started on bootup. These programs wait for some event to happen (for example, somebody trying to print to your printer) and then take action.
Daemons are started and stopped by scripts in the directory /etc/init.d/ . These scripts are called in a standard way; they take the options start, stop, restart, and reload. For example, to stop the firewall script, you could type
/etc/init.d/firewall stop
A runlevel determines the set of services/daemons that are allowed to run at any given point. When Linux enters a runlevel it will start and stop services so that the set of running services matches the services that are allowed to run at that time. Runlevels are important primarily when booting and shutting down the system.
There are eight runlevels that exist on your system, although in practice only five of them are distinct:
The init command is used to enter these runlevels. For example, if you wanted to enter single-user mode, you would type (as root)
init 1
You will usually not use this command directly.
Your system identifies the services to start and stop at each runlevel using symbolic links. Each runlevel gets its own directory: runlevel 0 uses /etc/rc0.d, runlevel 1 uses /etc/rc1.d, and so on.
Inside each of these directories is a set of symbolic links. The symbolic links point to the scripts in /etc/init.d. Each link is named in the following way:
If for some reason you need to modify the services that run at some runlevel, you have two options: you can modify the symlinks directly, or you can use the update-rc.d command. For example, to disable the firewall from all runlevels, you would type
update-rc.d -f firewall remove
This would remove all the symbolic links in the rc.d directories, but it will not touch the original script in /etc/init.d . Note that this command alters the services you run permananently; if you just wanted to temporarily stop the firewall, you would type
/etc/init.d/firewall stop
and the firewall would be disabled until you rebooted or turned it on again.
Files to configure your Internet connectivity are scattered throughout /etc. Each file controls a different aspect of networking:
If you have a network card in your machine, the file /etc/network/interfaces determines how the network card is configured. The network card is named eth0. A line in the interfaces file reading
auto eth0
determines whether you connect on to the Internet upon booting up. If the line is present and not commented out, then your network card attempts to connect to the Internet (or whichever network you are on) upon booting. If you are not always connected to the Internet, you may want to comment this line out:
#auto eth0
Then you would type the following command (as root) to start networking manually:
ifup eth0
Many daemons and applications write information to logfiles, recording status messages and errors. When things go wrong, it is often worth looking at the log files for errors and other unusual events.
Programs are supposed to keep their logfiles in the /var/log directory. Some files and directories of note include:
Often you will not want to look through these files manually. Rather, you will want to search through the files for expressions using grep.