PDA

View Full Version : CHMod & Terminal




Ensign Paris
Jul 28, 2002, 07:04 AM
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



mmmdreg
Jul 28, 2002, 07:14 AM
try "chmod" :)

Ensign Paris
Jul 28, 2002, 07:23 AM
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
Jul 28, 2002, 07:45 AM
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:

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:

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:

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!!!

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
Jul 28, 2002, 11:36 AM
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

Rower_CPU
Jul 28, 2002, 12:13 PM
You also might try BatChmod:
http://www.versiontracker.com/moreinfo.fcgi?id=12057&db=mac

It's a GUI utility that does the same thing...plus it has a nice Force Empty Trash command as well.

mmcneil
Jul 28, 2002, 01:58 PM
Originally posted by Rower_CPU
You also might try BatChmod:
http://www.versiontracker.com/moreinfo.fcgi?id=12057&db=mac

It's a GUI utility that does the same thing...plus it has a nice Force Empty Trash command as well.

thanks!!