Linux: ls -l prints only question marks:

I have a problem with listing of some directory with ls -l:

$ ls -l ./directory
-????????? ? ? ? ?            ? file001.txt
-????????? ? ? ? ?            ? file002.txt

and just ls works good:

$ ls ./directory
file001.txt file002.txt

What is wrong?


Solution 1:

Check the permissions of ./directory : if you have read permissions but not execute permissions on this directory, then you have enough rights to read the list of files in that directory, but you can't actually use these files or get information about them.

example session:

$ cd /tmp/
$ mkdir /tmp/test
$ touch /tmp/test/file
$ ls -la test/
total 44
drwxr-xr-x  2 myself myself  4096 janv.  5 11:01 .
drwxrwxrwt 42 root   root   54242 janv.  5 11:01 ..
-rw-r--r--  1 myself myself     0 janv.  5 11:01 file
$ chmod a-x /tmp/test # remove execute permission for all
$ ls -la test/
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
-????????? ? ? ? ?            ? file
$ ls -ld test/
drw-r--r-- 2 myself myself 4096 Jan  5 11:01 test/
$ cat test/file 
cat: test/file: Permission denied
$ chmod a+x /tmp/test # readd execute permission for all
$ ls -la test/
total 44
drwxr-xr-x  2 myself myself  4096 janv.  5 11:01 .
drwxrwxrwt 42 root   root   54242 janv.  5 11:01 ..
-rw-r--r--  1 myself myself     0 janv.  5 11:01 file
$ ls -ld test/
drwxr-xr-x 2 myself myself 4096 Jan  5 11:01 test/
$ cat test/file
$

Some ls versions show error messages when they can't display information about files.