What is an executable directory?
If
o+w
is set the directory changes colors to a background green, what does this mean? Why doesn't it do it forug+w
, but only foro+w
?Additional question after reading the comments: Is making a directory executable a security risk? If so, why?
1 Answer
Colors
The coloring is controlled by the DIR_COLORS*
files that reside under `/etc. For example on Fedora 19 I have the following 3 files:
$ ls -l /etc/DIR_COLORS*
-rw-r--r--. 1 root root 5004 Jan 20 2014 /etc/DIR_COLORS
-rw-r--r--. 1 root root 5682 Jan 20 2014 /etc/DIR_COLORS.256color
-rw-r--r--. 1 root root 4646 Jan 20 2014 /etc/DIR_COLORS.lightbgcolor
The coloring is completely cosmetic and keys off of the output that ls
is generating. You can disable it like so:
$ ls --color=never <other options>
The DIR_COLORS*
files can be viewed, they're just text, and have decent commenting, explaining their functionality. This line is why it's displaying as green:
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
Executable directories
Directories need to be executable so that user's can cd
into them and run commands. Without that bit, the directories cannot be accessed.
$ mkdir adir
$ chmod 644 adir
$ cd adir
bash: cd: adir: Permission denied
The reasons behind this are already extensively discussed in this other U&L Q&A titled: Execute vs Read bit. How do directory permissions in Linux work?.
/
,/bin
, and numerous other directories are globally executable? Are you also aware that when the op originally asked, he was also only setting the 'user' and 'group' bits, and not other?