Linux Know-How provides a collection of introductory texts on often needed Linux skills.


File Access Permissions

chmod perm filename

(=change mode) Change the file access permission for the files you own (unless you are root in which case you can change any file). You can make a file accessible in three modes: read (r), write (w), execute (x) to three classes of users: owner (u), members of the group which owns the file (g), others on the system (o). Check the current access permissions using:

ls -l filename

If the file is accessible to all users in all modes it will show:

rwxrwxrwx

The first triplet shows the file permission for the owner of the file, the second for the group that owns the file, and the third for others ("the rest of the world"). A "no" permission is shown as "-".

When setting permissions, these symbols are used: "u"(=user or owner of the file), "g"(=group that owns the file), "o"(=others), "a" (=all, i.e., owner, group and others), "="(=set the permission to), "+"(=add the permission), "-"(=take away the permission), "r"(=permission to read the file), "w"=(write permission, meaning the permission to modify the file), "x"(=permission to execute the file).

For example, this command will add the permission to read the file junk to all (=user+group+others):

chmod a+r junk

This command will remove the permission to execute the file junk from others:

chmod o-x junk

Also try here(lnag_basics.html#file_permissions) for more info.

You can set the default file permissions for the new files that you create using the command umask (see man umask).


Last Update: 2010-12-16