2.3. Post-Installation Procedures
After you have completed installing the Linux software, you should be able to reboot the system, log in as root, and begin exploring the system. (Each distribution has a different method for doing this; follow the instructions given by the distribution.)
Before you strike out on your own, however, there are some tasks you should do now that may save you a lot of grief later. Some of these tasks are trivial if you have the right hardware and Linux distribution; others may involve a little research on your part, and you may decide to postpone them.
2.3.1. Creating a User Account
In order to start using your system, you need to create a user account for yourself. Eventually, if you plan to have other users on your system, you'll create user accounts for them as well. But before you begin to explore you need at least one account.
Why is this? Every Linux system has several preinstalled accounts, such as root. The root account, however, is intended exclusively for administrative purposes. As root you have all kinds of privileges and can access all files on your system.
However, using root can be dangerous, especially if you're new to Linux. Because there are no restrictions on what root can do, it's all too easy to mistype a command, inadvertently delete files, damage your filesystem, and so on. You should log in as root only when you need to perform system administration tasks, such as fixing configuration files, installing new software, and so on. See "Maintaining the System" in Chapter 10 for details.[*]
For normal usage, you should create a standard user account. Unix systems have built-in security that prevents users from deleting other users' files and corrupting important resources, such as system configuration files. As a regular user, you'll be protecting yourself from your own mistakes. This is especially true for users who don't have Unix system administration experience.
Many Linux distributions provide tools for creating new accounts. These programs are usually called useradd or adduser. As root, invoking one of these commands should present you with a usage summary for the command, and creating a new account should be fairly self-explanatory.
Most modern distributions provide a generic system administration tool for various tasks, one of which is creating a new user account.
Again, other distributions, such as SUSE Linux, Red Hat Linux, or Mandriva, integrate system installation and system administration in one tool (e.g., yast or yast2 on SUSE Linux).
If all else fails, you can create an account by hand. Usually, all that is required to create an account is the following:
We don't want to go into great detail here: the particulars of creating a new user account can be found in virtually every book on Unix system administration. We also talk about creating users in "Managing User Accounts" in Chapter 11. You should be able to find a tool that takes care of these details for you.
Keep in mind that to set or change the password on the new account, you use the passwd command. For example, to change the password for the user duck, issue the following command:
# passwd duck
This will prompt you to set or change the password for duck. If you execute the passwd command as root, it will not prompt you for the original password. In this way, if you have forgotten your old password but can still log in as root, you can reset it.
2.3.2. Getting Online Help
Linux provides online help in the form of manual pages. Throughout this book, we'll be directing you to look at the manual pages for particular commands to get more information. Manual pages describe programs and applications on the system in detail, and it's important for you to learn how to access this online documentation in case you get into a bind.
To get online help for a particular command, use the man command. For example, to get information on the passwd command, type the following command:
$ man passwd
This should present you with the manual page for passwd.
Usually, manual pages are provided as an optional package with most distributions, so they won't be available unless you have opted to install them. However, we very strongly advise you to install the manual pages. You will feel lost many times without them.
In addition, certain manual pages may be missing or incomplete on your system. It depends on how complete your distribution is and how up-to-date the manual pages are.
Linux manual pages also document system calls, library functions, configuration file formats, and kernel internals. In "Manual Pages" in Chapter 4, we describe their use in more detail.
Besides traditional manual pages, there are also so-called Info pages. These can be read with the text editor Emacs, the command info, or one of many graphical info readers available.
Many distributions also provide documentation in HTML format that you can read with any web browser, such as Konqueror, as well as with Emacs.
Finally, there are documentation files that are simply plain text. You can read these with any text editor or simply with the command more.
If you cannot find documentation for a certain command, you can also try running it with either the -h or -help option. Most commands then provide a brief summary of their usage.
2.3.3. Editing /etc/fstab
In order to ensure that all your Linux filesystems will be available when you reboot the system, you may need to edit the file /etc/fstab, which describes your filesystems. Many distributions automatically generate the /etc/fstab file for you during installation, so all may be well. However, if you have additional filesystems that were not used during the installation process, you may need to add them to /etc/fstab in order to make them available. Swap partitions should be included in /etc/fstab as well.
In order to access a filesystem, it must be mounted on your system. Mounting a filesystem associates that filesystem with a particular directory. For example, the root filesystem is mounted on /, the /usr filesystem on /usr, and so on. (If you did not create a separate filesystem for /usr, all files under /usr will be stored on the root filesystem.)
We don't want to smother you with technical details here, but it is important to understand how to make your filesystems available before exploring the system. For more details on mounting filesystems, see "Mounting Filesystems" in Chapter 10, or any book on Unix system administration.
The root filesystem is automatically mounted on / when you boot Linux. However, your other filesystems must be mounted individually. Usually, this is accomplished with the command:
# mount -av
in one of the system startup files in /etc/rc.d or wherever your distribution stores its configuration files. This tells the mount command to mount any filesystems listed in the file /etc/fstab. Therefore, in order to have your filesystems mounted automatically at boot time, you need to include them in /etc/fstab. (Of course, you could always mount the filesystems by hand, using the mount command after booting, but this is unnecessary work.)
Here is a sample /etc/fstab file, shortened by omitting the last two parameters in each line, which are optional and not relevant to the discussion here. In this example, the root filesystem is on /dev/hda1, the /home filesystem is on /dev/hdb2, and the swap partition is on /dev/hdb1:
# /etc/fstab # device directory type options # /dev/hda1 / ext3 defaults /dev/hdb2 /home ext3 defaults /dev/hdb1 none swap sw /proc /proc proc defaults
The lines beginning with the "#" character are comments. Also, you'll notice an additional entry for /proc. /proc is a "virtual filesystem" used to gather process information by commands such as ps.
As you can see, /etc/fstab consists of a series of lines. The first field of each line is the device name of the partition, such as /dev/hda1. The second field is the mount point--the directory where the filesystem is mounted. The third field is the type; Linux ext3fs filesystems should use ext3 for this field. swap should be used for swap partitions. The fourth field is for mounting options. You should use defaults in this field for filesystems and sw for swap partitions.
Using this example as a model, you should be able to add entries for any filesystems not already listed in the /etc/fstab file.
How do we add entries to the file? The easiest way is to edit the file, as root, using an editor such as vi or Emacs. We won't get into the use of text editors here. vi and Emacs are both covered in Chapter 19.
After editing the file, you'll need to issue the command:
# /bin/mount -a
or reboot for the changes to take effect.
If you're stuck at this point, don't be alarmed. We suggest that Unix novices do some reading on basic Unix usage and system administration. We offer a lot of introductory material in upcoming chapters, and most of the remainder of this book is going to assume familiarity with these basics, so don't say we didn't warn you.
2.3.4. Shutting Down the System
You should never reboot or shut down your Linux system by pressing the reset switch or simply turning off the power. As with most Unix systems, Linux caches disk writes in memory. Therefore, if you suddenly reboot the system without shutting down cleanly, you can corrupt the data on your drives. Note, however, that the "Vulcan nerve pinch" (pressing Ctrl-Alt-Delete in unison) is generally safe: the kernel traps the key sequence and passes it to the init process, which, in turn, initiates a clean shutdown of the system (or whatever it is configured to do in this case; see "init, inittab, and rc Files" in Chapter 17). Your system configuration might reserve the Ctrl-Alt-Delete for the system administrator so that normal users cannot shut down the network server that the whole department depends upon. To set permissions for this keystroke combination, create a file called /etc/shutdown.allow that lists the names of all the users who are allowed to shut down the machine.
The easiest way to shut down the system is with the shutdown command. As an example, to shut down and reboot the system immediately, use the following command as root:
# shutdown -r now
This will cleanly reboot your system. The manual page for shutdown describes the other available command-line arguments. Instead of now, you can also specify when the system should be shut down. Most distributions also provide halt, which calls shutdown now. Some distributions also provide poweroff, which actually shuts down the computer and turns it off. Whether it works depends on the hardware and the BIOS (which must support APM or ACPI), not on Linux.