Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 7485  / 1 Year ago, thu, december 15, 2022, 11:14:18

I have a bunch of media files (that only need to be 644) that were a mix of various permissions. Some were group or global writable so I thought, just to be safe, I'll chmod them all back to 644.



The problem is there is a directory hierarchy and for all the directories that were caught in this ls -l displays them as:



d????????? ? ? ? ?            ? Dirname


If I chmod that to 744, it's fixed.



My question is: What's going on here? Do directories need to be executable?


More From » permissions

 Answers
4

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.


[#31943] Saturday, December 17, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
montwim

Total Points: 103
Total Questions: 112
Total Answers: 120

Location: Vietnam
Member since Mon, Mar 14, 2022
2 Years ago
montwim questions
;