2

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.

Kalle Richter
  • 6,180
  • 21
  • 70
  • 103
  • 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 '14 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 '14 at 22:31
  • For the sake of completeness regarding the LANGUAGE=C ls -la command: see http://askubuntu.com/questions/473402/how-to-invoke-a-kde-application-with-another-language-equivalent-of-language-c/473456?noredirect=1#473456 – Kalle Richter May 28 '14 at 14:43

1 Answers1

3

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.

  • 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? – Kalle Richter May 18 '14 at 08: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 '14 at 19:54