CHMod & Terminal

Ensign Paris

macrumors 68000
Original poster
Nov 4, 2001
1,781
0
Europe
Hi

Could some body tell me what command I can put into the terminal to edit the CHMOD number of a file? Normally I don't have to do it because my web server is Win2k, but I am creating a new CGI based site which I am hosting from my macs apachie server. Anyone know how?

Thanks,
Ensign
 

Ensign Paris

macrumors 68000
Original poster
Nov 4, 2001
1,781
0
Europe
Hey

right, could you explain slightly more indepth?


I need to set stuff to chmod 777 or 755 but I can't find an App to do it so I guess I will have to use the terminal.
Ensign
 

Taft

macrumors 65816
Jan 31, 2002
1,319
0
Chicago
Use search characters.

You can put search characters into the filename of almost any command. For instance, with ls, you can list the contents of a directory. By default, it will list all of the files in a directory. But try this:
Code:
ls x*
This will list all of the files in a directory that start with x. *x* would list all files containing an x. * would list all files again.

So with chmod, you usually do something like this:
Code:
chmod 755 theFile.txt
This changes the permissions of theFile.txt so that the owner can read, write and execute and the group and the world can only read and execute. Now try:
Code:
chmod 755 *
This will change the permissions of all files in a directory to those listed above.

Finally, there is a switch that allows you to traverse directories recursively allowing you change permissions on a directory and any files and subdirectories inside it.

Use this command carefully!!! Especially when executing it as root!!!
Code:
chmod -R 755 theDir
This command will switch the permissions on a directory and all files and subdirectories inside it. You can also put search characters in the name of this command, switching the permissions of multiple files and directories recursively, all at one time.

Taft
 

mmcneil

macrumors regular
Sep 4, 2001
219
44
Indianapolis, IN
chmod warnings

Be particularly cautious when trying to change files that start with a period (.). Do not use wildcards with a period e.g. .* - this causes the system to change not only the files but the current directory . and the superior directories .. I was duly impressed, amazed, and very chagrined to learn this:rolleyes:

There are a couple of other command that can help delete files that seem to be recalcitrant.

chflags -R noschg file1, file2
chflags -R nouchg file1, file2



Each seems to work in a slightly different situation

I guess this answers the question I asked in a different forum - are you still serving on a W2K platform:D