Discussion Locked

I need to understand chmod command

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
can people her explain this in detail: how to let users not alter but to download stuff then change?

5 replies

by dmiles

The chmod command changes the access permissions (read, write, and execute) for a file or directory, for the owner of the file, the group associated with that file, or everybody else.
To see what the existing permissions on a file are, use the command ls -lg filename:

stealth% ls -lg gimprc-old
-rw-r--r-- 1 ariel rad 5388 May 29 1996 gimprc-old

The owner can read and write to this file, the members of the group rad can read it, and everyone else can read it. (For more information about how to figure out the permissions, see the ls command.)

You can add permissions for u (the user, i.e. the owner), g (the group), or o (others, i.e. everyone else).

In order to add permissions, use chmod + and in order to take them away, use chmod -.

The permissions you can add are r (read), w (write), and x (execute).

Let's see how this works:

Suppose I want to add execute permissions for the members of the group in the above example. Then I use the command chmod g+x gimprc-old:

stealth% chmod g+x gimprc-old
stealth% ls -l gimprc-old
-rw-r-xr-- 1 ariel 5388 May 29 1996 gimprc-old

Suppose now that I want to remove read permissions for everyone (the 'other') category). Then I use the command chmod o-r gimprc-old:

stealth% chmod o-r gimprc-old
stealth% ls -l gimprc-old
-rw-r-x--- 1 ariel 5388 May 29 1996 gimprc-old

You can use chmod to change the permissions of all files and directories within a directory, including the directory itself, by using the command chmod -R settings directory-name where settings is [ugo][+-][rwx] and directory-name is the name of the directory you want to change.

More information about the chmod command is available by using the command man chmod

by jim-h

You might want to try typing ?man chmod? in your UNIX box. If you do not have the man pages then you can review them here:
http://www.hmug.org/man/1/chmod.html

Based on what you said I am ?guessing? that you would want to setup something like 744; which would give the owner full rights but everyone else ONLY Read level access.

This is a neat little CHMOD Calculator if you understand the concepts of CHMOD itself:
http://javascriptkit.com/script/script2/chmodcal.shtml

Good Luck!
-Jim

This discussion is closed to new replies.