Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm having trouble with my webserver an noticed that the output of ls -la /var/www contains irregularily ? instead of permission digits, e.g.

$ LANGUAGE=C ls -la /var/www/
ls: cannot access /var/www/dokuwiki: Permission denied
ls: cannot access /var/www/joomla: Permission denied
ls: cannot access /var/www/..: Permission denied
ls: cannot access /var/www/index.html: Permission denied
ls: cannot access /var/www/mediawiki: Permission denied
ls: cannot access /var/www/html: Permission denied
ls: cannot access /var/www/postfixadmin: Permission denied
ls: cannot access /var/www/awffull: Permission denied
ls: cannot access /var/www/index.lighttpd.html: Permission denied
ls: cannot access /var/www/drupal: Permission denied
ls: cannot access /var/www/sarg: Permission denied
ls: cannot access /var/www/.: Permission denied
ls: cannot access /var/www/trac: Permission denied
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
d????????? ? ? ? ?            ? awffull
d????????? ? ? ? ?            ? dokuwiki
d????????? ? ? ? ?            ? drupal
d????????? ? ? ? ?            ? html
-????????? ? ? ? ?            ? index.html
-????????? ? ? ? ?            ? index.lighttpd.html
d????????? ? ? ? ?            ? joomla
d????????? ? ? ? ?            ? mediawiki
d????????? ? ? ? ?            ? postfixadmin
d????????? ? ? ? ?            ? sarg
d????????? ? ? ? ?            ? trac

sudo ls -la /var/www produces

$ sudo ls -la /var/www/
insgesamt 52
drwxr--r-- 11 www-data www-data 4096 Mai 17 23:37 .
drwxr-xr-x 15 root     root     4096 Apr 27 14:51 ..
drw-r--r--  2 www-data www-data 4096 Mai 12 15:34 awffull
drwxr-xr-x  2 www-data www-data 4096 Apr 21 23:55 dokuwiki
drwxr-xr-x  2 www-data www-data 4096 Apr 21 23:55 drupal
drw-r--r--  2 www-data www-data 4096 Apr  3 14:21 html
-rw-r--r--  1 www-data www-data  177 Apr 21 23:54 index.html
-rw-r--r--  1 www-data www-data 3568 Mai  1 11:13 index.lighttpd.html
drwxr-xr-x  2 www-data www-data 4096 Apr 21 23:55 joomla
drwxr-xr-x  2 www-data www-data 4096 Apr 27 18:58 mediawiki
drwxr-xr-x  2 www-data www-data 4096 Apr 21 23:55 postfixadmin
drw-r--r--  2 www-data www-data 4096 Mai 12 15:05 sarg
drwxr-xr-x  2 www-data www-data 4096 Apr 21 23:55 trac

which corresponds to the result of my chmod and chown invokations (after the problem occured). The directories dokuwiki, drupal, joomla, mediawiki trac are mount points (options rw,bind) of another partitions. I invoked ls with both mounted and unmounted directories. Everything worked like a charm on Ubuntu 13.10.

share|improve this question
    
Which filesystem is /var/www? Smell as corruption. (By the way, prepending LANGUAGE=C to your command will give the messages in english like LANGUAGE=C ls -la). I would recommend a backup, unmount, and fsck the filesystem (in that order). –  Rmano May 17 at 22:02
1  
I think it's just because of the unusual drwxr--r-- permissions on the top level /var/www/ directory i.e. others are allowed to read but not execute the directory. Execute permission is needed to stat the directory contents. –  steeldriver May 17 at 22:31
    
For the sake of completeness regarding the LANGUAGE=C ls -la command: see askubuntu.com/questions/473402/… –  Karl Richter May 28 at 14:43

1 Answer 1

up vote 3 down vote accepted

It is caused by the fact that you don't have execute permission on the directories. Fix this by using chmod o+x directory. Make sure you don't make files executable unless you want them to be. It is not dangerous for directories to be executable. It only means you're allowed to traverse the directory.

share|improve this answer
    
Great, thanks! The solution was chmod a+x (I guess I'll have to do all operations on a backup again because permissions are messed up now), but at least I can ls my directory now :) Why doesn't ls fail and display such unclear output? –  Karl Richter May 18 at 8:57
    
a+x and o+x is identical in that context, because the user and group owners already had it. I don't know exactly why you need the executable bit to see permissions, but permissions are irrelevant if you're not allowed to access the directory anyway. It's unusual to have read but not execute, although it is common to have execute without read. –  Jo-Erlend Schinstad May 18 at 19:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.