4

1) I'm not sure how nested directory permissions work.

Suppose I have the following directories/files and permissions:

~/Private/ 700
~/Private/Group 770
~/Private/Group/Public 777

Is Public really public?

2) If I want to make Private really private, does it matter whether I use -R when doing 'chmod 700'?

3) I have read that Ubuntu uses a word readable home folder by default, and refuses to fix it. But when I do 'ls -lh' I get this: drwx------ (700, right?). So which is it? Have they changed their mind about the home folder?

Note: I'm on a Ubuntu 12 VM

4
  • 1 & 2: Try it. You have the tools in front of you. 3: That is not what I see on a couple of Ubuntu installs here. May 25, 2012 at 17:05
  • @DanielAndersson I tried it before writing the question (and I couldn't access Public), but some things didn't make much sense. For instance, I remember that in CentOS I had to chmod 700 .ssh before being able to use it. But why would I need to do that, if ~/ was already 700? Can't leave this to chance, that's why I'm asking it here. May 25, 2012 at 18:31
  • @DanielAndersson 3: What is it that you don't see? 700 or 755? During installation I have chosen to encrypt the disk and home, maybe that changed the permissions? May 25, 2012 at 18:35
  • 1
    The home directories I see on the different Ubuntu installations are all 755. May 25, 2012 at 19:02

1 Answer 1

3
~/Private/ 700
~/Private/Group 770
~/Private/Group/Public 777

A user who isn't the owner of ~/Private/, and ~/Private/Group will not be able to get into the Public folder with these permissions.

On Unix/Linux you must add the execute bit for a user to be able to traverse (change into or through) a directory. But you don't need to grant read access. So try this instead. But keep in mind, that the user must know that the Group and Public directories exist, there will be no way for them to use ls to see if they exist unless they are also granted read access.

~/Private/ 711
~/Private/Group 771
~/Private/Group/Public 777

does it matter whether I use -R when doing 'chmod 700'

If you run that command you are going to change the permissions of every file an directory below the directory you target, if you have anything with different permissions, then they will get lost. I suspect you would also be adding the execute bit to a lot of regular files, which is generally undesirable.

You might want to use a command like this instead. This will only change the permissions on the directory, and subdirectories, without changing permissions on the files.

find {directory_path} -type d -print0 | xargs --null -n 1 chmod 0700

A similar command to change only the files would look like this.

find {directory_path} -type f -print0 | xargs --null -n 1 chmod 0600
2
  • As for point 3, add a new user and see what happens.
    – Zoredache
    May 25, 2012 at 19:44
  • Perfect, thanks. Just a correction: "there will be know way" -> "there will be no way" May 26, 2012 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .