19

Context: I added a drive to my machine, and for whatever reason, I am unable to access a directory(?) on it.

ls -l

ls: cannot access Downloads: No such file or directory
total 56
d?????????  ? ?    ?        ?            ? Downloads
drwxr-xr-x 26 user    12288 Aug 12 23:29 foo

ls -a

.  ..  Downloads  foo

cd

bash: cd: Downloads: No such file or directory

touch

touch: cannot touch ‘Downloads’: File exists

mkdir Downloads

mkdir: cannot create directory ‘Downloads’: File exists

cat Downloads

cat: Downloads: No such file or directory

file Downloads

Downloads: cannot open `Downloads' (No such file or directory)

mv Downloads down

mv: cannot stat ‘Downloads’: No such file or directory

Furthermore, the following commands do not remove the file(?), as root or otherwise:

rm Downloads
rm -rf Downloads
rmdir Downloads

One more piece of information, bash auto-completes Downloads, so bash also seems to think it is there.

Beefy_Swain
  • 441
  • 1
  • 5
  • 14

6 Answers6

1

ls: cannot access Downloads: No such file or directory total 56 d????????? ? ? ? ? ? Downloads drwxr-xr-x 26 user 12288 Aug 12 23:29 foo

This is a typical case of having only read perms on a dir and no exec perms. And the other command outputs give the show that you don't have write perms either. To understand why this happens you'll have to know about inodes, dentries and the path lookup process of the kernel

1

D, you haven't described the situation around the issue, but here goes,

First does the directory appear in your file manager? According to your listing

d?????????  ? ?    ?        ?            ? Downloads

The directory "exists" but, without any discernable/set/assigned permissions, nor does it belong to a user or a group. In fact, on the face of it, read access is completely blocked. Again, describe the situation around this issue, meaning how did you arrive at this point?.

As an experiment , boot a live distro, and access that way, get the listing for Downloads and either assign "standard" directory permissions 755 or delete the directory. From time to time i have experienced what seem to be "bad writes" of files with the same issue and have had to jump to a live distro to delete them from my daily driver. If you CAN access the Download directory from the live distro, then recover it's contained data "off world" before you delete the directory. It's better to recreate the directory correctly once you are back in normal operation.

0

I had a file show up in a similar state. I was able to fix it by running fsck.

0

you should run this commond:

umount Downloads

look like this : https://www.linuxquestions.org/questions/linux-newbie-8/ls-shows-directory-attributes-as-question-marks-942157/

0

I had the same issue with a directory from which I unmounted a SMB share. The only thing that helped was to reboot the machine.

Rea
  • 1
0

One of the situations under which one can get this error is when the directory name is changed from outside the terminal, or in a more general term, the directory path becomes invalid, while being inside the directory within the terminal. If that is the case, you may want to use cd .. followed by ls to confirm.

learner
  • 101