Changing File Permissions
lass at media 10/24/05


Show File Permissions

ls -l -- when you list a file with the "-l" option, it will show the file permissions and ownership

The first column is the permissions.
The third column is the owner.
The fourth column is the group.
The fifth column is the size.

If the listing is a directory, the first letter of the first column will be a "d"

The first column, permissions, is read in 4 groups:
drwxrwxrwx
d (of is a directory), rwx (user permissions), rwx (group permissions), rwx (all permissions)

-rw-r--r--  1 root root 0 Oct 24 12:09 amy
-rwxrwxrwx  1 root root 0 Oct 24 12:10 dog
-rwxr-xr-x  1 root root 0 Oct 24 12:10 everett
drwxr-xr-x  2 root root 4096 Oct 24 12:23 lass
If the letter doesn't appear, it will be substituted with a "-". That means that particular permission is not granted.

In the above example, "lass" is a directory that the owner can read, write, and execute, and everyone else can only read and execute. "amy" is a file (not a directory) that the owner can read and write (but not execute) and everyone else can only read. All the files above are owned by the user "root".

Change File Permissions

To change permissions, use the "chmod" command. Use "+" to add permissions or "-" to take away permissions. For example,

chmod a-x * = take away "execute" from "all" (* means all the files in this directory)

chmod u+w * = give "write" permission to the owner, or "user" (* means all the files in this directory)

chmod a+x cam move = give everyone permission to execute the cam and move programs

Some definitions: a = all g = group u = user r = read w = write x = execute