This first part of chapter 5 "Module 5: Managing Users" covers understanding user properties and user databases. It also examines the technique of managing users for a single host. It starts by exploring the actual database files that contain information about users and moves on to the system tools available to manage the files automatically. (from the book Linux Administration, A Beginner's Guide, third edition by Steven Graham and Steve Shah, McGraw-Hill/Osborne, ISBN:0072225629, 2002).
When users log in to the system, they expect an environment that can help them be productive. This first program that users encounter is called a shell. If youíre used to the Windows side of the world, you might equate this to command.com, Program Manager, or Windows Explorer (not to be confused with Internet Explorer, which is a Web browser).
Under UNIX, most shells are text based. The shell we discuss in further detail in Module 6 is the default shell for the root user, the Bourne Again Shell, or BASH for short. Linux comes with several shells from which to chooseóyou can see most of them listed in the /etc/shells file. Deciding which shell is right for you is kind of like choosing a favorite beerówhatís right for you isnít right for everyone, but, still, everyone tends to get defensive about his or her choice!
What makes UNIX so interesting is that you do not have to stick with the list of shells provided in /etc/shells. In the strictest of definitions, the password entry for each user doesnít list what shell to run so much as it lists what program to run first for the user. Of course, most users prefer that the first program run be a shell, such as BASH.
Under DOS, you are used to having the autoexec.bat and config.sys files run automatically when you start up the system. Since DOS is a single-user system, the two programs not only perform system functions such as loading device drivers, but they also set up your working environment.
UNIX, on the other hand, is a multiuser environment. Each user is allowed to have their own configuration files; thus, the system appears to be customized for each particular user, even if other people are logged in at the same time. The configuration file comes in the form of shell scriptóa series of commands executed by the shell that starts when a user logs in. In the case of BASH, itís the file .bashrc. (Yes, there is a period in front of the filenameófilenames preceded by periods, also called dot files, are hidden from normal directory listings unless the user uses a special option to list them.) You can think of shell scripts in the same light as batch files, except shell scripts can be much more capable. The .bashrc script in particular is similar in nature to that of autoexec.bat.
Most Linux/Unix software likes to store information in directories or files that begin with a . in your home directory. Some examples are .netscape and .kde. Also, there are several files that contain customizable options for some of your favorite applications:
.emacs The configuration file for emacs; venture into this when you would like to start learning Lisp.
.bashrc/.profile Configuration files for BASH.
.tcshrc/.login Configuration files for tcsh.
.xinitrc This script overrides the default script that gets called when you log in to the X Window System.
.Xdefaults This file contains defaults that you can specify for X Window System applications.
To see all of the files in your home directory, simply type ls -al.
When you create a userís account, you should provide a default set of dot files to get the user started. If you use the tools that come with Linux, you donít need to worry about creating these filesóthe tools automatically do this for you. However, there is nothing stopping you from customizing these files to make them site specific. For example, if you have a special application that requires an environment variable to be set, you can add that to the dot files that are copied to the new userís home directories.
Creating a new user means not only creating the userís home directory and setting up the environment, it also means making it possible for the user to send and receive e-mail. Setting up a mailbox under Linux is quite easy, and if you use the tools that come with Linux to create the account, you donít even have to do this yourself!
Mailboxes are kept in the /var/spool/mail directory. Each user has a mailbox that is based on their login name. Thus, if a userís login is jyom, their mailbox will be /var/spool/mail/jyom. All mailboxes should be owned by their respective owners with the permissions set so that others cannot read its contents. (See the chown, chmod, and chgrp commands in Module 6 for details on how to do this.)
An empty mailbox is a zero-length file. To create a zero-length file anywhere in the system, you simply use the touch command, like so:
[root@ford /root]# touch myfile
This will create a new file called myfile in the current directory.
This chapter is from Linux Administration, A Beginner's Guide, third edition, by Graham and Shah. (McGraw-Hill/Osborne, 2002, ISBN: 0072225629). Check it out at your favorite bookstore today. Buy this book now.