Assigning accounts

/etc/passwd

One type of user on whose behalf you manage the provider of resources is a user who actually has an account on the machine. This means that they have been assigned a particular 16-bit uid which is used by the system to determine the resources they can access and the type of access they are authorized to perform.

Although it is not necessary that a uid be assigned to an account, most of the time the association of an id with an individual is through the file /etc/passwd (or some distributed/networked equivalent).

This file should be thought of as a database (since it is a database:-) in CSV (colon-separated-values in this case) form, in which the very first field, which we call the logname, is the key. In other words, there should be only one line with a particular logname.

The attributes assigned to the record with a particular logname as key are a password (kept usually in another file such as /etc/shadow), a uid, a gid (group id), a description, a home directory, and a shell.

There can be more than one logname with a particular uid, and probably most entries have the same shell (/usr/bin/bash or some other pathname specifies it). The home directory is often assigned as a subdirectory of some system directory such as /home/ followed by another directory whose name itself is the logname. Sometimes multiple lognames share a single home directory, in which case they almost surely share the same uid. There are a few accounts that might have /dev/null as their home directory, typically "system" accounts for which no one will ever log in and run programs directly.

assigning accounts

First take a look at example02 for a script that we will use to run all administrative actions on our machines.

See example04 for account preparation and example03 for the script to actually run on each machine to create the accounts. Be sure and run this using admin-action as explained above. Make yourself (as root) a directory called /opt/accounts and download the scripts you will need which are zipped at the top of the example sheets. Be sure and put the admin-action script into some common directory and make it executable.

After unzipping these files in your /opt/accounts directory you will have the script assignUsers and the file userLines in the directory, and you can run the command


admin-action assignUsers

You will also need to add a couple of root user lines as will be explained in the lab using samples contain in the zip.