User IDs and Passwords

Users in the Unix world are most commonly referred to by their usernames, but that is not how the underlying operating system sees them. Every user on a system is assigned a user ID (UID) that uniquely identifies that user. UIDs are integers ranging from 0 to 65535. UID 0 is reserved for the superuser (commonly named root, but the name can in fact be anything, as long as the UID is 0). Convention dictates that “system” users (user accounts that represent system processes, not actual human beings) have UIDs below 100.

Because everything in Unix is a file, the file security permissions are of utmost importance. The owner and group owner of a file is stored in the inode (index node) at the filesystem level. This is stored as the UID integer, not as the username. To see an example of this, do a long directory listing on a directory where some files are owned by users that no longer exist on the system:

# cd /var/spool/mail/
# ls -l
total 1295140
-rw-rw---- 1 adamh       mail         0 Jan  6 11:04 adamh
-rw-rw---- 1 alex        mail  86311334 Jan  8 06:27 alex
-rw-rw---- 1        2047 mail         0 Dec  2  2006 alice
-rw-rw---- 1        2003 mail   1600945 Jan  7  2009 bob
-rw-rw---- 1        2080 mail     95086 Sep  9  2008 carol

In this example, we are looking in the directory /var/spool/mail, where the mail spool files for each user are stored, with filenames corresponding to user account names. The files adamh and alex are owned by users adamh and alex, respectively, whereas the file alice is owned by UID 2047, bob is owned ...

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.