User Accounts Any user that wants to use Unix system must have a login name or username defined to the system. This login name identifies the user. When a newuser is added to unix systems systems administrator assigns it a unique login name which is associated with a number called UID or user identification number. This UID is the systems way of identifying the user. Typically, a newuser is also assigned to a group, group is collection of users in one department or working on one project identified with one group name. Each group is identified with its GID number or group identification number. For example ls -la command will produce following result. in /usr/ssb directory for sandeep. drwxrwxrwx -rw-rw-rwdrwxrwxrwx drwxrwxrwx -rwxr-xr-x
2 1 3 2 1
ssb ssb ssb ssb ssb
users users users users users
1024 348 1024 1024 1726
Nov Oct Oct Sep Oct
3 30 21 18 23
12:50 09:46 10:38 11:17 12:11
dusg dxi12 gnu logs mon12.ksh
It tells us that first dusg is a directory owned by ssb in users group with 1024 bytes created on Nov 3 at 12:50 PM. So together UID and GID determine what kind of access rights a user has to files and directories.
These are procedures to add a new user to system. • • • • • • •
Get user's name and create a login id based on name, decide which group and which other groups user need. Enter this data into /etc/passwd file and /etc/group file. Assign a password to this account, also set password aging, account expiration date, resource limits and privileges. Create a home directory for user, preferably on the same disk where other home directories exist. chown and cghrp to give new user ownership of his home directory. Set umask for new files that are created, set disk quota, mail and printing system for new user. Test this account.
How to enter user in passwd file. Once you have all the data about user name things like. • • • •
name of user which primary group and what secondary groups. which shell does the user wants to use,ksh or csh or sh. password for this account.
a typical entry in a /etc/passwd looks like sbajwa:*:111:35:Sandeep Bajwa:/usr/sbajwa:/bin/ksh each field is separated by a : which tells that login id is sbajwa password is nothing * means nothing. UID is 111 Group id is 35 name is Sandeep Bajwa home directory is is /usr/sbajwa /bin/ksh is the shell being used after this is done,the first thing to do is to assign a new password. for this above sbajwa account, new password can be assign by passwd command. i.e. passwd sbajwa Then at next prompt assign the new password. Other options. • • • • •
-f Force the user to change her password at next login. -s List password aging date for the specified user. -a Used with -s to list data for all users. -l Lock the account so the user can't log in. (-u unlocks it). -d delete the password for this user.
To create a home directory for this user use mkdir and chown commands. cd /usr/ mkdir sbajwa chown sbajwa sbajwa
Since this user gets ksh when logs in we have to give him a default .profile file, if a user logs in with csh then .login file is used. These files are helpful for taks suc as • • • •
Setting the path search, so that programs can be run which are not in home directory. file protection with umask value. Definition of terminal type and initialization of terminal. Other customization functions.
here is a sample .login file to be used with csh
umask 022 setenv PATH /usr/local/bin:/usr/bin:~/bin setenv EDITOR emacs mesg y set prompt = ' `hostname` -\!> ' setenv TERM=vt100
A sample .profile file with same values. will be
umask 022 export PATH=/usr/local/bin:/usr/bin:~/bin export EDITOR=emacs mesg y
PS1='`hostname` -\!>' export TERM=vt100
Fundamentals of Unix Unix commands User Accounts Shell Programming File Systems Networking Backups Security Installing software Installing Hardware Performance Some Useful Scripts Your suggestions and comments are welcome. Please e-mail me Copyright reserved with Sandeep S Bajwa.