Tuesday Tiny Techie Tip

Permissions

Everybody's seen a UNIX long directory listing before:
hugo% ls -lga
total 26
drwxr-xr-x  2 jeffy    se            512 May  9 16:13 .
drwxr-xr-x  3 jeffy    se           1024 May  9 16:09 ..
-rw-r--r--  1 jeffy    se             28 May  9 16:12 Makefile
-rwxr-xr-x  1 jeffy    se          24576 May  9 16:13 foo
-rw-r--r--  1 jeffy    se             57 May  9 16:13 foo.c

The first field with all the rwx-'s tells us the permissions of the file, the second tells the number of hard links to the file (see the tip from December 10th for details on hard links), the third tells the owner's userid, the fourth the group ownership, the fifth the size in bytes, then the date of last modification and finally the filename. This week we'll talk about the permissions.

The permission string consists of 10 characters.

The first character indicates the type of file. It is usually a "d" indicating a directory, an "l" indicating a symbolic link, or a "-" indicating a plain old vanilla file. There are a number of other possibilities, but they are rare, showing up mostly in /dev.

The other nine characters are divided into three groups of three. The first group shows the permissions given to the user who owns the file. The second group shows the permissions given to any member of the group of the file. The third shows the permissions given to every other person in the universe.

The first character of each triplet is an "r" if that entity is allowed to read the file. The second character is a "w" if that entity is allowed to write to the file. The third is an "x" if that entity is allowed to execute the file.

So for example:


-rwxr-xr--  1 jeffy    se          24576 May  9 16:13 foo

That tells us that jeffy can read, write, or execute foo, anyone in the "se" group can read it or execute it, and anyone else can read it but can't execute it.

Next week I'll get into how to use chmod(1) to modify the permissions.


Tuesday Tiny Techie Tip -- 13 May 1997
Forward to (05/20/97)
Back to (05/06/97)
Written by Jeff Youngstrom

Up to the TTTT index

Tuesday Tiny Techie Tips are all © Copyright 1996-1997 by Jeff Youngstrom. Please ask permission before reproducing any of this material.