Difference between executable directory vs executable files
No, the executable permission for directories means that you can enter the directory, making it your present working directory using cd
, and see which files it contains.
It's useful to think of a directory just as a file which is a list of file names.
Read bit - If set, you can read this list. If you have a directory named books:
You can
ls
books and you'll get a list of the files it contains (-l
won't work however).You can use command-line completion i.e.
touch books/bo
+Tab to getbooks/bookfile
.You cannot make books your working directory,
cd
won't work.
Write bit - You can modify this list names on it. You can only do this if the execute bit is also set.
Execute bit - You need this permission if you want to:
- Have any access to files within the directory.
- Modify details of the list itself. You can add, rename or delete names on the list, but this also requires write permission on the directory.
Setting the execute bit on a directory does not in any way affect the files themselves, but it does affect your access to them. For instance if you have write and execute access for a directory, you can move, rename and delete files, even if you can't write into the files themselves.
Related videos on Youtube
Shady Programmer
Updated on September 18, 2022Comments
-
Shady Programmer over 1 year
Does having an executable permission on a directory mean that the files inside it are executable too even if the files don't explicitly have executable permissions set ?
-
ridgy over 7 yearsNo. Execution permission on directores means search permission (for reading file attributes and cd'ing into the directory). To execute a file, you must have execute permission on that file.
-
Zanna over 7 yearsSee the permissions tag wiki
-
Wildcard over 7 yearsAlso relevant: unix.stackexchange.com/a/251302/135943
-
Bob over 7 yearsSee also: askubuntu.com/questions/83788/…
-
-
Shady Programmer over 7 yearsThat explains a lot actually! Now I understand why some directories appear with a colored background overlay on their name in terminal emulator.
-
Arronical over 7 yearsI've added a bit of info about all permissions, thinking of a directory as a folder full of files isn't as useful as thinking of it as a file in itself, which is just a list of files when it comes to permissions.