Help with CHMOD


I admit, I use Mac OS and Windows all the time, and Unix would be neat to learn if I had the time. But until then, anyone recommend a beginners’ guide to CHMOD?

Or at the minimum, how do I set the CHMOD for a directory so that no one visiting my site could view the file listings in the directory, but can still access the individual files on there.

Like if they visit the directory images/, they get a Forbidden message. But if they visit images/logo.png, they can view the image.

Thanks a zillion!



Hi Alex,

Actually, the easiest way to do what you need is to create a file named ‘index.html’ in that directory. It doesn’t matter what’s in it, but when someone tries to browse that directory they’ll get that file instead of a directory listing.

As for chmod, most Mac and Windows FTP clients have a permissions editor built in (I know Fetch for the Mac does). But if you’re interested in learning more about chmod or how to use it from a command line, this appears to be a pretty decent tutorial:

  • Jeff @ DreamHost
  • DH Discussion Forum Admin


Thanks. I was hoping to be more “elaborate” but the simpliest solutions often work best.

Yes, I know that I can change CHMOD with standard FTP clients, I’ve done it before, but I never get the results I have expected. I just wanted to learn more about it and maybe find something useful :slight_smile:



Oh, okay. Yeah, that link I sent you should have all the details (chmod has a lot of options so it’ll probably be better explained there than I can do it myself). :>

  • Jeff @ DreamHost
  • DH Discussion Forum Admin


It’s actually not done via CHMOD, which refers to setting permissions, but via a .htaccess file. Create a plain text file called .htaccess in the directory you want to protect, with the following content:

Options -indexes

Yes, that’s it, just one line. :slight_smile:



Thanks, that helps, but only one problem: that one line seems to conflict with another item I have in some of my other .htaccess files:

<files ~ “.inc$”>
Order allow,deny
Deny from all

I have this to protect my PHP include files from prying eyes. Apache outputs an 500 Internal Server Error message when the stuff above and the thing you told me are included in the same file. I mean I can’t work around this, but any additional help would be nice. Thanks a bunch!



Hmmmm… I’ve never used the commands you’re using, so I don’t know what sort of conflict it’s creating. I am not really much of a UNIX goddess, sad to say. But maybe someone else here knows more?




You should be able to use multiple directives in one .htaccess file. I’d just put Options -indexes at the to, and then put the tags. Also, you can put
Options -indexes
in your domain root directory and then
Options +indexes
in another directory tree within it. Using the Apache directive is the easiest way to disable directory browsing for your whole site, although putting a blank index page might look a little friendlier than Apache’s error page.

There are a number of useful options which can be enabled using .htaccess; you can check the docs at which are admittedly somewhat cryptic at times.