CHMod & Terminal

Discussion in 'Mac Help/Tips' started by Ensign Paris, Jul 28, 2002.

  1. Ensign Paris macrumors 68000

    Ensign Paris

    Joined:
    Nov 4, 2001
    Location:
    Europe
    #1
    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
     
  2. Ensign Paris thread starter macrumors 68000

    Ensign Paris

    Joined:
    Nov 4, 2001
    Location:
    Europe
    #3
    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
     
  3. Taft macrumors 65816

    Taft

    Joined:
    Jan 31, 2002
    Location:
    Chicago
    #4
    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
     
  4. mmcneil macrumors regular

    Joined:
    Sep 4, 2001
    Location:
    San Diego, CA
    #5
    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
     
  5. Rower_CPU Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #6
  6. mmcneil macrumors regular

    Joined:
    Sep 4, 2001
    Location:
    San Diego, CA
    #7

Share This Page