Chmod Selectively/Recursively

From ArchWiki

Jump to: navigation, search
Image:Tango-document-new.png This article is a stub.
This typically means the article is a placeholder for more content to come. Knowledgeable users are encouraged to help expand the article.

Change mod recursively Code:

chmod -R xxx directory

where -R means "recursively", xxx is the permissions string in octal notation (e.g. 644, or whatever) and "directory" is the directory you want to change permissions in.

Note: 755 is -rwxr-xr-x, and 777 is -rwxrwxrwx, (7=4+2+1, while r=4, w=2, x=1)


Since folders should be chmod to 755 and files to 644 in PHP-.Nuke, you need a means of applying the above command only to files, or only to folders. No problem with pipes, just do Code:

find directory/ -type d -print0 | xargs -0 chmod 755
find directory/ -type f -print0 | xargs -0 chmod 644

The "/" after the directory name is important here. The "-type" option selects the appropriate file type (directory of file), the "-print0" option terminates the names wih a zero, so that filenames with blanks are recognized properly (since filename terminator is now a zero and not a blank). xargs applies the following command (chmod) to any arguments passed to it by the pipe, -0 indicates again that the argument separator is a zero and not a blank.

If you use some Windows program, search for some settings. I know that WS_FTP has a graphical interface to chmod, see for example How to chmod using WS_FTP. Just select all the files you want the change to apply to and follow the instructions in that link.

Personal tools