On Mac OS X, it's relatively easy to prevent people from seeing the files contained in your home directory: chmod 700 ~

I'd like to perform a variation of that. I want it so that when people open /Users/stalepretzel, they only see one folder listed: Public. From there, I'd like to set the permissions of Public so that people can enter that folder and read anything that's not specified otherwise.

Again, to clarify, I'd like it so another non-admin user could execute:

$ cd /Users/stalepretzel; ls
$ cd Public
All     the     contents     of
my      public  folder

I'm afraid this isn't possible. A user can't access any file or folder anywhere in the tree of a directory for which he doesn't have read permissions. If the user does have read permissions for a directory (and all its superdirectories), he can ls and see all the files it contains.

It might not feel quite so tidy, but if you want to prevent users from being able to ls your home directory you'll have to create Public somewhere outside of ~. If it's easier for you to access your own public directory from ~/Public, make a symlink (e.g. ln -s ~/Public /Users/Shared/stalepretzel).

  • Ah, good idea. I'll probably accept this if there are no other posts soon. Thanks! – stalepretzel Aug 6 '09 at 2:29

I don't think you can do any better than (standard Unix stuff):

$ chmod 711 ~/
$ chmod g-rx,o-rx ~/*
$ chmod 755 ~/Public

to make your home directory traversable, but unreadable, and everything else apart from 'Public' inaccessible.

[Unix permission recap - Execute bits on a directory allow traversal, Read bits allow seeing the contents.]

Unfortunately that doesn't allow anyone to see that your Public folder exists - and there's no way to do that, because the existence of the Public folder depends upon being able to read your home directory as that's the "file" that contains it (names are in parent directories, permissions are part of the file inode.)


Open your home dir to be read:

$ chmod 0744 ~

and hide everything in there:

$ chmod 700 ~/*

then open up just the Public directory:

$ chmod 0744  ~/Public

Note: Edited the command order to make it correct

  • This doesn't work. This allows people to view a listing of my entire home directory (bad), and doesn't allow people to view the contents of , or enter, the Public directory (bad). Additionally, users aren't able to open files contained in my Public directory if they know their locations (bad). Uh oh! – stalepretzel Aug 6 '09 at 1:44
  • The idea is to open up your home directory, then hide everything inside it, then open just the Public folder. You'll have to remember to hide any new files/dirs in home not in Public, but it does what you asked. I edited the command order to make it more clear – Robert Swisher Aug 6 '09 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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