I am getting question marks and not able to identify the type of file displayed using ls -l. File types are always displayed as ???.

Can you suggest a solution here?

  • 4
    Please edit the question to include the ls output that you are describing. – Haxiel Dec 29 '18 at 5:33
  • That happens on non-posix filesystems like FAT32 or NTFS. – 炸鱼薯条德里克 Dec 29 '18 at 6:12

If ls -l shows a question mark (?) as the first character on the line, it means that the file type is not a normal one recognized by the system. The file is not a regular file, not a directory, not a symbolic link, etc.

This can happen when you mount a non-native filesystem (for example a Solaris filesystem with doors). In this case you may or may not be able to interact with the file by opening it.

Most commonly, this happens when the filesystem has become corrupted. In this case, unmount the filesystem and run fsck. You may have lost some data.

There's no option for ls to show the numerical value that encodes the file type. If you want to show the numerical file type, you can use commands such as

strace -e lstat ls -ld the_file
strace -e lstat stat the_file
perl -e 'printf "0%o\n", (stat($ARGV[0]))[2]' the_file

Knowing this numerical value is typically of little use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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