Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have created directories in root. I am looking for the chmod command to allow all users read and write permissions to a specific directory. I have done chmod 775 for a file but I need this for a directory. This includes permissions on all files and sub directories.

Thanks for any help.

share|improve this question

migrated from stackoverflow.com Mar 31 '10 at 13:29

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 11 down vote accepted

0775 is rarely correct for a file. The following will add the appropriate desired permissions to the appropriate type, without disturbing other existing permissions:

find somedir \( -type d -exec chmod u+rwx,g+rwx,o+rx {} \; -o -type f -exec chmod u+rw,g+rw,o+r {} \; \)

See the man page for find to help decipher that.

share|improve this answer

For all users to have read and write access, that would be 0777 which is a bit dangerous, especially if you are running a webserver. Like @unwind said:

chmod -R 0777 /mydirectory Will allow all users read and write access to all files and folders within that directory

Depending on your purpose, you may want to read about sticky bits, which allow all users to create new files, but not to delete or edit other files in a directory:

chmod +t /mydirectory

Also, in case you didn't know man chmod will bring up the manual page for the chmod command, which you can search for the text "recursive" by typing /recursive

share|improve this answer

That's not how the Unix protection model works, you can't set permissions recursively. You need to set them on each directory, all the way "down".

Of course you can do the setting recursively, but that only means "go through and set these permissions on all files and folders below", which is not how I understand your question.

To do do that, use the -R option to chmod:

$ chmod -R 0755 /my-cool-directory
share|improve this answer
    
@unwind -- I mean every file and sub directory of a directory I chmod has read and write permission's for all. Is that what this command does? Thanks –  chrissygormley Mar 31 '10 at 12:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.