What does x on a linux directory mean?
Archive - Originally posted on "The Horse's Mouth" - 2009-07-21 15:40:56 - Graham EllisTrick question (I don't ask too many, I hope ... and those that I do ask are designed to be thought provoking):
What does the x bit in permission strings mean?
Most delegates who've done a bit of Unix or Linux before will tell me it's the exexcutable bit - says whether a file can be run as a program direct from the command line, and for a plain file they are correct. But for a directory, it means Access of should I say Axess?
One a directory, the r setting still means "readable" but without the x set on, I can only read the file names - I cannot access the full details of each file, nor can I delve deeper into the directory.
To illustrate this, I temporarily turns the "x" off on one of my directories and did some directory listings:
[trainee@easterton ~]$ chmod a-x dbn
[trainee@easterton ~]$ ls dbn
dbn/ac_20090716 dbn/mediawiki-1.14.0.tar.gz
dbn/apache-tomcat-5.5.27.tar.gz dbn/mysql-5.1.34-linux-i686-glibc23.tar.gz
dbn/httpd-2.2.11.tar.gz dbn/palace_of_westminster.jpg
dbn/jdk-6u14-linux-i586.bin dbn/php-5.2.9.tar.gz
dbn/latmjdemo.war dbn/somewhere_else
dbn/mediawiki-1.13.5.tar.gz
[trainee@easterton ~]$ ls -l dbn
total 0
?--------- ? ? ? ? ? dbn/ac_20090716
?--------- ? ? ? ? ? dbn/apache-tomcat-5.5.27.tar.gz
?--------- ? ? ? ? ? dbn/httpd-2.2.11.tar.gz
?--------- ? ? ? ? ? dbn/jdk-6u14-linux-i586.bin
?--------- ? ? ? ? ? dbn/latmjdemo.war
?--------- ? ? ? ? ? dbn/mediawiki-1.13.5.tar.gz
?--------- ? ? ? ? ? dbn/mediawiki-1.14.0.tar.gz
?--------- ? ? ? ? ? dbn/mysql-5.1.34-linux-i686-glibc23.tar.gz
?--------- ? ? ? ? ? dbn/palace_of_westminster.jpg
?--------- ? ? ? ? ? dbn/php-5.2.9.tar.gz
?--------- ? ? ? ? ? dbn/somewhere_else
and as you can see, you're able to see what's there, but not do much more.
Is this used / useful? There are places within the operating system that you'll find one just one of r and x on a directory, but advise for newcomers on our Linux Basics course is that - for a directory - you should normally treat them as a pair.