ls: cannot access file: No such file or directory

80,349

Solution 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

Solution 2

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.

Share:
80,349

Related videos on Youtube

Beefy_Swain
Author by

Beefy_Swain

Updated on September 18, 2022

Comments

  • Beefy_Swain
    Beefy_Swain almost 2 years

    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.

    • Zumo de Vidrio
      Zumo de Vidrio over 7 years
      Perhaps your filesystem has been corrupted. Are you able to do any action in a different OS?
    • Kit
      Kit about 7 years
      I would say that the metadata is corrupted or unreadable by the current OS. If you "repair" it there, it may work or it may become permanently inaccessible anywhere. Proceed with caution (and backups)
    • Foo Bar
      Foo Bar almost 7 years
      Perhaps this is the same as askubuntu.com/questions/548930/…
  • Beefy_Swain
    Beefy_Swain almost 9 years
    updated post with contex
  • r0berts
    r0berts over 7 years
    It would be nice to be more specific - e.g. by booting a live distro, or on reboot. Maybe you found what the core problem was - e.g. improperly unmounted network share, or permissions on his new disk that do not make sense to his current system, etc.
  • Kamil Maciorowski
    Kamil Maciorowski almost 6 years
    How will sole unmounting help? It's like repairing a car by putting it out of sight. If the link leads to the real solution, please cite it here; the target site may change or disappear. Is the solution substantially different than what other answers suggest?
  • sbecker
    sbecker almost 3 years
    I have no idea how unmounting helps. But it did help for me. I had mounted an smb share to that directory. The smb share didn't exist anymore though. After unmounting, I was able access the directory as per usual.
  • Community
    Community over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.