View Full Version : change permissions via terminal

04-02-2003, 12:55 AM
i am trying to change permissions on a remote puter via ssh. i don't know the commands to change the permissions. i know the whole rwx thing but i don't know how to change the existing settings.

04-02-2003, 12:56 AM
oh yeah. i am the admin on that puter plus i have root access.

04-02-2003, 01:23 AM
man chmod


--Zed :cool:

04-02-2003, 01:34 AM
i looked at that but i still don't understand what to do. i want to make the file have the following permissions. drwxrwxr-x so what is the command or commands i must use?

04-02-2003, 01:37 AM
i want to make the file have the following permissions. drwxrwxr-x so what is the command or commands i must use?

ok well first off the d mean directory so this is not a file..

chmod 775 <name>

Will do the trick!!

1 = x
2 = w
4 = r


--Zed :cool:

04-02-2003, 03:47 PM
Zed's listing of the numerical equivalences was a good start...but to put them into practice...

When executing a chmod command, it is generally of the format chmod ### <filename> (where ### are three single digits). The first of the digits specifies what the owner of the file is allowed to do with it. The second digit specifies what the user group that is assigned to the file can do with it. The third digit specifies what everyone else can do with it.

These digits are where zed's 1, 2 and 4 come in. If you want one of the three sets of people (owner, group, others) to be able to execute the file (x), you'll put 1 in their position in the chmod command. If write (w), you'll put 2. If read (r), 4. So if you want the owner to be able to read, the user group to be able to read and everybody else to have no access to file.txt, you type chmod 440 file.txt.

So, you ask, where do the 7s and 5s come from if the pallette consists only of 1, 2 and 4? It comes from combining them. If you want somebody to be able to read and execue a file, then you will add the number for read (4) to the number for execute (1) and get 5. The owner will generally have a setting of 7 (read/4 + write/2 + execute/1) for any executable files...and 6 (read/4 + write/2) for non-executables.

So where do the big long drwxrwxr-x sort of strings come from? This string is divided into 4 parts. The first character is dedicated to letting you know if the file is a directory (d), has the set-UID bit set, etc. The directory (d) character is the only one you will run into on a regular basis. The next three characters tell you what the owner can do with the file: read (r), write (w), execute (x)...in that order. If there's a dash (-) in one of the positions, it means the owner doesn't have permission to perform the action that corresponds to that position in the string. The next three characters correspond in the same way to the user group permissions. And the last three, correspond in the same way to everyone else's permissions.

Knowing what these characters mean, you can also use chmod in combination with them instead of the numbers. Remember these abbreviations:

Person Abbreviations
u = user (owner)
g = group
o = others (everybody else)
a = all (all of the above, everybody)

Permission Abbreviations
r = read
w = write
x = execute

You can then use chmod to add or subtract permissions from these different people. The syntax to add permissions is:

chmod <person abbrev.>+<permission abbrev.> <file name>

For example, if you want the owner/user to have write access to file.txt, you'll just type: chmod u+w file.txt

Taking permissions away is just as simple. You just replace the plus sign (+) with a minus sign/dash (-). So to take read permission away from the group type: chmod g-r file.txt

I hope that all made sense. If you still don't quite get it, let us know. I'm sure that between zed and I we can straighten it out. = )

04-03-2003, 12:24 AM
thanks. that clears it up.