Previous Page | Next Page

  1. Introduction
  2. Abbreviated Boot
  3. The Boot Process
  4. Startup and Run Levels
  5. Initialization Scripts
  6. Runlevel Scripts
  7. Login Process
  8. Bash Shell
  9. Filesystems
  10. LILO, Kernel and Root Filesystem
  11. The Kernel
  12. Passwords, Users, Groups, and Quotas
  13. The Environment
  14. The /etc/sysconfig directory
  15. The /proc filesystem
  16. Process Control
  17. Devices
  18. Daemons Services
  19. Inetd and Network Services
  20. Programs and Libraries
  21. Security and PAM
  22. The printer services
  23. Mouse support with gpm
  24. Mail
  25. News
  26. UUCP
  27. LDAP
  28. NFS and RPC
  29. Samba, NetBIOS, WINS, nmbd
  30. Identd (auth)
  31. Telnet and FTP
  32. Apache web server
  33. DNS and named
  34. How X Works
  35. X Scripts
  36. Support for Text
  37. Keymapping for Programs
  38. Keycode Table
  39. Example Keymap File
  40. Terminfo Commands
  41. VT100 ESC sequences
  42. Kernel Revisited
  43. Configuration Files
  44. Credits

Linux Passwords, Users, Groups, and Quotas

There are several characteristics of passwords and how they are or should be stored on your system. They should be:

  1. In a file that is readable only by root.
  2. In a one way hash format.

The actual password is not stored on your system, but its one way hash value is.

One way hash

A one way hash is a function. The password is given to the function, and the function generates an output. This function is special since it has the following characteristics:

  1. It is easy to generate a output from it that will produce the same output for the same password.
  2. It is very difficult to generate the original input from the produced output. An example would be like a sine to inverse sine function, square to square root, etc.

There are one way hash protocols that are used for this purpose. One popular protocol used on Linux is called MD5. Therefore the way "crack" password cracking programs work is to get a copy of your system password file and try to guess at the password, running it through the one way hash function until it gets a match. This is why short passwords are not good. There is another solution to help this situation called salting, but I'm not sure it is implemented yet on Linux. I think it may be, but is only a two character string, and its value may be stored in /etc/password, which is world readable so it may not be effective in increasing protection against any of your users. Basically, when a short password is received it is "salted" with extra characters at random. The extra salt characters must be stored somewhere on the system in a secure location and used to generate the hashed password value for comparison to the stored value anytime the user logs in. The "longer" salted password and the associated output will make it more difficult for crack programs to guess the original password.

Protecting your hashed password value

In the past, the user's password was stored in a file called "/etc/passwd". This file needs to be readable by all users, however, since programs such as the shell that run at the user's privilege level need to access information in it such as the user's name. A normal listing of the /etc/passwd file shows the user access settings:

-rw-r--r--   1 root     root          775 May  5 12:43 /etc/passwd

This can cause a problem compromising system security. This is why shadow passwords was implemented. See the section on the login process for a description of the /etc/passwd file and how it is used.

Linux Shadow Passwords

The shadow password suite allows the following features to be added to your system:

  • A configuration file to set login defaults (/etc/login.defs)
  • Utilities for adding, modifying, and deleting user accounts and groups (chage,
  • Password aging and expiration
  • Account expiration and locking
  • Shadowed group passwords (optional)
  • Double length passwords (16 character passwords) NOT RECOMMENDED]
  • Better control over user's password selection
  • Dial-up passwords

Replacement programs included are chfn, chsh, id, login, newgrp, passwd, and su. Additional programs included are chage, dpasswd, gpasswd, groupadd, groupdel, groupmod, groups, grpck, lastlog, newusers, pwck, pwconv, pwunconv, useradd, userdel, and usermod. Also libshadow.a is a library included for compiling programs that need to use the user password files or user passwords.

If your system did not come with shadow passwords and you are going to install it you will want to read the Shadow-Password-HOWTO and roughly do the following.

  1. Find the latest shadow password suite that will work on your system
  2. Backup a copy of your files listed above that the shadow password suite will replace.
  3. Install the shadow password suite.
  4. Remove old man pages that may interfere with you seeing the correct replacement man pages that came with the shadow password suite.
  5. run pwconv which creates /etc/npasswd and /etc/nshadow
  6. Backup /etc/passwd and copy the files /etc/npasswd and /etc/nshadow to /etc/passwd and /etc/shadow respectively.
  7. Be sure the /etc/shadow and /etc/passwd owners and permissions are the same as shown in listings in this manual.
  8. Verify you can login
  9. When you are sure the system runs OK, remove backup files such as the backed up copy of /etc/passwd.
  10. You may need to upgrade your xlock program to get X working. xlock is the screen saver used to lock the screen.
  11. xdm presents the login screen for X. You may need to upgrade xdm.

The shadow password suite of software allows for the user's passwords to be stored in a file, /etc/shadow with the following permissions:

-r--------   1 root     root          729 May  5 12:43 /etc/shadow

This file can only be read by root and looks like:

root:!!:11077:0:99999:7:-1:-1:134550548
bin:*:10942:0:99999:7:::
daemon:*:10942:0:99999:7:::
adm:*:10942:0:99999:7:::
lp:*:10942:0:99999:7:::
sync:*:10942:0:99999:7:::
shutdown:*:10942:0:99999:7:::
halt:*:10942:0:99999:7:::
mail:*:10942:0:99999:7:::
news:*:10942:0:99999:7:::
uucp:*:10942:0:99999:7:::
operator:*:10942:0:99999:7:::
games:*:10942:0:99999:7:::
gopher:*:10942:0:99999:7:::
ftp:*:10942:0:99999:7:::
nobody:*:10942:0:99999:7:::
xfs:!!:10942:0:99999:7:::
gdm:!!:10942:0:99999:7:::
postgres:!!:10942:0:99999:7:::
squid:!!:10942:0:99999:7:::
mark:!!:10942:0:99999:7:-1:-1:134550548
george:!!:11082:0:99999:7:-1:-1:134549460

I have modified the password entries. Its format is:

login:password:Daysince:Daysafter:Daysmust:dayswarn:daysexpire:daysince:reserved

Where:

  • login - login name
  • password - password in encrypted form, which is 13 to 24 characters long.
  • Daysince - Days since Jan 1, 1970 that the password was changed
  • Daysafter - Days before the password may be changed
  • Daysmust - Days after which the password must be changed
  • dayswarn - Days before the password will expire ( A warning to the user)
  • daysexpire - Days after the password expires that the account is disabled
  • daysince - Days since Jan1, 1970 that the account is disabled.
  • reserved - Reserved field.

Shadow password utility programs

The following programs are available as tools to manipulate shadow passwords and user password entry information/requirements.

  • chage - Used to change information on the required number of days between user password changes and date of the last change. Non-root users can only use chage with the -l option to see when their password will expire. Options are:
    1. l -
    2. m - Set the minimum days between password changes
    3. M - Set the maximum days a password will be valid for.
    4. W - Sets the number of days the user is warned before their password expires.
    5. d - Used to change the time of the last password change.
    6. E - Set a date the user's account will not be accessible.
    7. I - The days of inactivity after a password has expired until the account is locked.
  • pwconv - Used to create the file /etc/shadow from the file /etc/passwd. In short, it converts to a shadow password system. It uses the file /etc/login.defs to get PASS_MIN_DAYS, PASS_MAX_DAYS, and PASS_WARN_AGE values to help generate the /etc/shadow file.
  • pwunconv - Uses the files /etc/passwd and /etc/shadow to create /etc/passwd, then deletes /etc/shadow. In short, it removes the shadow password system.
  • grpconv - Creates /etc/gshadow form the file /etc/group.
  • grpunconv - Uses the files /etc/passwd and /etc/shadow to create /etc/passwd, then deletes /etc/shadow.
  • pwck - Checks the /etc/passwd and /etc/shadow files for errors.
  • grpck - Checks the /etc/group and /etc/sgroup files for errors.
  • usermod - Modify a user's account. Options are:
    1. d - Change the user's home directory
    2. e - Change the user's account expiration date in the format YYYY-MM-DD.
    3. f - Change the number of days after the password expires to when the account is disabled.
    4. g - Change the user's initial login group name.
    5. G - Supplemental groups that hte user is also a member of.
    6. l - Change the user's login name
    7. p - The encrypted password
    8. s - Change the name of the user's login shell
    9. u - The numerical value oif the users ID
    10. L - Lock a user's password, disabling it with a ! infront to the value in the /etc/shadow file.
    11. U - Unlock a user's password
    See the manpage on usermod for more information.
  • crypt - The password encryption function.

Other user management programs:

  • chfn - Change a user's finger information
  • chsh - Change a user's shell
  • gpasswd - Used to administer the /etc/group file and /etc/gshadow file.
    • -A - Define group administrator.
    • gpasswd -a user group - Adds a user to a group.
    • gpasswd -d user group - Deletes a user from a group.
    • -M - Define group members.
    • gpasswd -R group - Removes a group disabling access to it using the newgrp command.
    • gpasswd -r group - Remove a group password.
  • groupadd - Create a new group.
  • groupdel - Delete a group
  • groupmod - Modify a group ID or name.
  • id - Print group or user ID numbers for the specified user
  • newgrp - Allows a user to log in to a new group.
  • newusers - Used to update many user accounts at a single time by reading a file with user names and clear text passwords.
  • passwd - Allows a user or root to change their or their user's passwords.
  • su - Allows a user to run in a shell with a different user and group ID. A user may become root with this command if they know the root password.
  • useradd - Used to create a new user or update information.
  • userdel - Used to delete a user. The user's home directory can be deleted using the -r option.

Shadow password files

  • /etc/passwd - Where the user information is stored.
  • /etc/shadow - Further user information and user password and password management information is stored here.
  • /etc/group - The group file of the format:

    groupname:password:GID:user_list

    An example file:

    root:x:0:root,mark
    bin:x:1:root,bin,daemon
    daemon:x:2:root,bin,daemon
    sys:x:3:root,bin,adm
    adm:x:4:root,adm,daemon
    tty:x:5:
    disk:x:6:root
    lp:x:7:daemon,lp
    mem:x:8:
    kmem:x:9:
    wheel:x:10:root
    mail:x:12:mail
    news:x:13:news
    uucp:x:14:uucp
    man:x:15:
    games:x:20:
    gopher:x:30:
    dip:x:40:
    ftp:x:50:
    nobody:x:99:
    users:x:100:
    floppy:x:19:
    utmp:x:22:
    xfs:x:101:
    console:x:102:
    gdm:x:42:
    pppusers:x:230:
    popusers:x:231:
    slipusers:x:232:
    postgres:x:233:
    slocate:x:21:
    squid:x:23:
    mark:x:500:
    george:x:501:
    
  • /etc/groups - May contain passwords that let a user join a group.
  • /etc/gshadow - Used to hold the group password and group administrator password information for shadow passwords. See the Shadow-Password-HOWTO.
    root:::root
    bin:::root,bin,daemon
    daemon:::root,bin,daemon
    sys:::root,bin,adm
    adm:::root,adm,daemon
    tty:::
    disk:::root
    lp:::daemon,lp
    mem:::
    kmem:::
    wheel:::root
    mail:::mail
    news:::news
    uucp:::uucp
    man:::
    games:::
    gopher:::
    dip:::
    ftp:::
    nobody:::
    users:::
    floppy:x::
    utmp:x::
    xfs:x::
    console:x::
    gdm:x::
    pppusers:x::
    popusers:x::
    slipusers:x::
    postgres:x::
    slocate:x::
    squid:x::
    mark:!::
    george:!::
    
  • /etc/login.defs - Used with shadow passwords to set initial PATH and other parameters including how often a user must change passwords and what is acceptable as a password. An example file:
    # *REQUIRED*
    #   Directory where mailboxes reside, _or_ name of file, relative to the
    #   home directory.  If you _do_ define both, MAIL_DIR takes precedence.
    #   QMAIL_DIR is for Qmail
    #
    #QMAIL_DIR	Maildir
    MAIL_DIR	/var/spool/mail
    #MAIL_FILE	.mail
    
    # Password aging controls:
    #
    #	PASS_MAX_DAYS	Maximum number of days a password may be used.
    #	PASS_MIN_DAYS	Minimum number of days allowed between password changes.
    #	PASS_MIN_LEN	Minimum acceptable password length.
    #	PASS_WARN_AGE	Number of days warning given before a password expires.
    #
    PASS_MAX_DAYS	99999
    PASS_MIN_DAYS	0
    PASS_MIN_LEN	5
    PASS_WARN_AGE	7
    
    #
    # Min/max values for automatic uid selection in useradd
    #
    UID_MIN			  500
    UID_MAX			60000
    
    #
    # Min/max values for automatic gid selection in groupadd
    #
    GID_MIN			  500
    GID_MAX			60000
    
    #
    # If defined, this command is run when removing a user.
    # It should remove any at/cron/print jobs etc. owned by
    # the user to be removed (passed as the first argument).
    #
    #USERDEL_CMD	/usr/sbin/userdel_local
    
    #
    # If useradd should create home directories for users by default
    # On RH systems, we do. This option is ORed with the -m flag on
    # useradd command line.
    #
    CREATE_HOME	yes
    
    
  • /etc/limits - Limits users resources when a system has shadow passwords installed.

Linux User Quotas

The ability to set quotas limits a user's disk storage by setting:

  1. The number of inodes the user or group may use.
  2. The number of disk blocks a user or group may use.

This limits the user's ability to use up all system resources. It only works on ext2 filesystems. Quotas must be set for each filesystem that the user may use. The kernel must have quota support compiled in.

Commands used to set quotas and limits are:

  • edquota(8) - Used to edit user or group quotas. This program uses the vi editor to edit the quota.user and quota.group files. If the environment variable EDITOR is set to emacs, the emacs editor will be used. Type "export EDITOR=emacs" to set that variable.
  • quota(1) - Display users' limits and current disk usage.
  • quotaoff(8) - Turns system quotas off.
  • quotaon(8) - Turn system quotas on.
  • quotacheck(8) - Used to check a filesystem for usage, and update the quota.user file.
  • repquota(8) - Lists a summary of quota information on filesystems.
  • ulimit - A bash builtin command for setting the processes a user can run.

Files:

  • /etc/mtab
  • quota.user - Resides on the filesystem quotas are being set on. Stores user quota information.
  • quota.group

This section only describes the tools and files involved in setting up user quotas. For complete instructions refer to the "Linux User's Guide" in the "Managing Users" section.