So, you own your home direcory /home/myusername, and have rwx permissions on it.
But a cd /home/myusername
gives a Permission denied?
That looks like you are not allowed to look at /home in the to begin with, before it comes to actually looking up myusername in that directory.
With sudo chmod 774 .*
in /home/myusername, you included the file ...
And /home/myusername/.. is the same as /home.
The permissions were applied as root, so the 4 is what applies to you a a normal user. this is r--, it does not contain the execute permission. On a directory, the execute permission is what allows you to look inside the directory.
The problem applies to all users that have their home directory under /home, as you already found out.
To change permissions on a file or directory entry non-recursively, use the
chmodcommand (see man chmod to read more about its specific options):
To change the owner of a file/directory recursively (affecting all descendants):
To change permissions bits of all files in a directory, recursively:
To change permissions bits of all directories:
It would be nice if you could just do this:
However, this has problems. It treats files and directories the same. The above command makes directories listable and readable by all users, but it also makes all files executable, which is usually what you do not want to do.
If we change it to
644, we get another problem:
The problem is that
644takes out the directory list bit, and this side effect prevents further traversal of the file tree. You could work around this issue by using
sudo, but you still end up with directories that are completely useless to non-root users.
The point is,
chmod -Rworks just fine in some cases (e.g.
chmod -R g-r), but not in cases where you want to mess with the
-xbit, since it operates on files and directories indiscriminately.