Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that allows public to upload small jpg's to a gallery. Works well but occasionally unwanted files are uploaded.

How do I make all files inherit public unreadable permissions in that single directory until I change it's permission to readable?

As some jpg's will have readable permissions and be live - making the folder unreadable is not an option.

share|improve this question

If you can't use a folder to wrap permissions then you quite rightly say that this needs to be done for each file. Since the permissions on a file are an attribute of the file itself, it is the responsibility of the file creator to set the permissions (as opposed to the OS). On this basis, if you are receiving files uploaded through a web app, it is the responsibility of that application to set the file permissions before writing to disk.

share|improve this answer

This should do it after the fact (from man chmod):

chmod --recursive o-r /path

To make it happen as the files are saved, you need to use a umask. Since you don't mention which language you're using take a look at How to set umask for a specific folder for some tips.

share|improve this answer

Your Answer


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.