Linux : ls -l은 물음표 만 인쇄합니다. 문제가 있습니다. $ ls -l ./directory -?????????

ls -l을 사용하여 일부 디렉토리를 나열하는 데 문제가 있습니다.

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

그리고 ls는 잘 작동합니다.

$ ls ./directory
file001.txt file002.txt

뭐가 잘못 되었 니?



답변

./directory읽기 권한이 있지만이 디렉토리에 대한 권한을 실행하지 않는 경우 권한을 확인하십시오. 그러면 해당 디렉토리의 파일 목록을 읽을 수있는 충분한 권한이 있지만 실제로 이러한 파일을 사용하거나 해당 파일에 대한 정보를 얻을 수는 없습니다.

세션 예 :

$ 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
$

일부 ls버전은 파일에 대한 정보를 표시 할 수 없을 때 오류 메시지를 표시합니다.


답변