Editing configuration files

Some of the tips in this book require that you edit configuration files by hand using a text editor. Under Ubuntu, system configuration files are usually located in the /etc folder. This is a root-owned folder so root powers are needed to alter files there.

In every tip requiring it, I'll tell you the exact line within the config file you'll need to change, so there's no need to fret over details. However, some general points about configuration files are worth noting.

First, bear in mind that configuration files are plain text format. They're never saved as anything more complicated, such as a rich-text file. Watch out for this if you have to create a new configuration file from scratch and save it for the first time. Secondly, configuration files often have the file extension .conf and usually not .cfg, as you might be used to under Windows. Some have no file extension at all, such as the /etc/fstab file that controls mounting of the basic storage devices on the system.

Within a configuration file a hash symbol (#) at the beginning of a line has a specific meaning. It tells Ubuntu to ignore that particular line.12

12. A hash at the beginning of a line in a file tells Ubuntu to ignore that line, with one exception. Script files, which contain chains of commands and are used throughout Ubuntu, start with a shebang—the characters #!. This tells Ubuntu that the file is a script. Usually following the shebang is the path to the shell that should run the script

Thus, comments within the file inserted by its creator to aid understanding by everybody else are preceded by a hash symbol. Additionally, many configuration files come with examples of settings that aren't active by default, and are therefore preceded by a hash. To enable that particular setting, all that's needed is to remove the hash.

Because the hash symbol is used to add comments to configuration files, you will often read instructions online where people advise you "comment out" a particular line. They simply mean add a hash to the front of the line so it will no longer be interpreted by Ubuntu.

A small amount of configuration files are in XML format, which are a little like HTML files—all the settings you can change are enclosed in tags (words surrounded by angle brackets). However, it's unlikely you will ever need to hand-edit an XML configuration file. For example, the GNOME desktop and associated applications used under Ubuntu use XML configuration files, but the gconf-editor program is provided to tweak these settings.

Was this article helpful?

0 0

Post a comment