Computer Science Fundamentals Operating Systems Subjective
Mar 12, 2013

How do you change file permissions in UNIX system?

Detailed Explanation

To change permissions on file or directory is chmod (change mode).The syntax involves using the command with three digits (representing the user (owner, u) permissions, the group (g) permissions, and other (o) user's permissions) Or by using symbolic representation. Each of the permission types is represented by either a numeric equivalent:

read=4, write=2, execute=1

or a single letter:

read=r, write=w, execute=x

A permission of 4 or r would specify read permissions. If the permissions desired are read and write, the 4 (read) and the 2 (write) are added together to make a permission of 6. Therefore, a permission setting of 6 would allow read and write permissions. Alternatively, you could use symbolic notation which uses the one letter representation for who and for the permissions and an operator, where the operator can be:

+ add permissions

- remove permissions

= set permissions

So to set read and write for the owner we could use "u=rw" in symbolic notation.

Syntax:-

chmod nnn [argument list] numeric mode

chmod [who]op[perm] [argument list]

symbolic mode where nnn are the three numbers representing user, group, and other permissions, who is any of u, g, o, or a (all) and perm is any of r, w, x.

Common Options

-f force (no error message is generated if the change is unsuccessful)

-R recursively descend through the directory structure and change the modes

Examples:-

If the permission desired for file1 is user: read, write, execute, group: read, execute, other: read, execute, the command to use would be

chmod 755 file1 or chmod u=rwx,go=rx file1

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback