Why does chmod 644 make directories inaccessible?
Solution 1:
As noted in the manpage for chmod
with relation to permissions:
The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for directories) (x), execute/search only if the file is a directory or already has execute permission for some user (X)
The executable bit on a folder is explained above as a 'search' permission; i.e. the execute bit merely allows you to access the folder in a file browser or to move to the folder from the terminal by running the cd
command or running ls ~/folder
to list the files in the folder.
The folder must be executable for the owner, although the superuser would still be able to access the folder as when using sudo
any file or directory can be accessed or deleted. In addition, directory and file permissions are explained further in this useful article at Stackoverflow.
It is also important to note that 'executing' the folder doesn't mean you are actually running any code or commands like when a executable binary or script is run.
For a home Desktop user (though perhaps not for your server) most folders within $HOME
have the execute permission set for user, group, and other if viewed with stat ~/myfolder
(excerpt below):
Access: (0755/drwxr-xr-x) Uid: ( 1000/ mike) Gid: ( 1000/ mike)
The standard permissions for folders within $HOME
are 755 or 775 and for files they are 644. However, the rest of the filesystem will differ. Again, folders must have the execute bit for the owner or they will not be able to be opened by him. It is important to be careful with chmod
when changing permissions and particularly when doing it recursively as the situation can quickly get messed up.
For more information, see man chmod
or the Ubuntu manpages online, and this article at Superuser.