How to Fix Directory with all Question Marks as Permissions

6,473

Solution 1

This may be an issue with the mounting service (e.g. Samba). Try restarting the Samba service on the remote host:

sudo service smb restart

Solution 2

I had this issue when running bind mounts on Docker. I restarted the Docker daemon and the file was correctly removed.

edit: I used WSL (Ubuntu 16.04) on Windows 10.

Share:
6,473

Related videos on Youtube

entpnerd
Author by

entpnerd

Updated on September 18, 2022

Comments

  • entpnerd
    entpnerd over 1 year

    I'm using CentOS 7 and trying to list a directory's contents but can't. When I try to list the contents, I get the following output:

    [entpnerd@myhost ~]$ ls -ali /data/sharedlogs/otherhost/
    ls: cannot access /data/sharedlogs/otherhost/vcs: Not a directory
    total 12
    2361284 drwxr-xr-x 4 root root 4096 Sep 26 14:40 .
    2359297 drwxr-xr-x 6 root root 4096 Apr 26 17:41 ..
    2362573 drwxr-xr-x 2 root root 4096 Mar 22  2017 tkr
          ? d????????? ? ?    ?       ?            ? vcs
    

    The output states that my directory, vcs, is "Not a directory", even though it should be, since this is where files have been previously logged. Additionally, the file permission bits are now all question marks, as is the owner, and (inexplicably) the inode ID.

    How can I get the file system to recognize my directory as a directory again?

    After trying everything that I've outlined below, the only path forward that I see is to ensure that the disk is backed up and run fsck (as suggested by this forum) or possibly just formatting the entire mount. Hopefully I find a simpler and less drastic solution.


    Some things I have tried:

    1. sudo: I tried running sudo ls but no difference in output.
    2. rm: I tried removing vcs to put it back but no luck. I tried this both with sudo and without, but no luck either. Oddly enough, when I try sudo rm it states Is a directory. I also tried rm with both the -r and the -d switches, with no luck also. The output I get from the rm command attempts are:

      [entpnerd@myhost ~]$ rm /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      [entpnerd@myhost ~]$ sudo rm /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory
      [entpnerd@myhost ~]$ sudo rm -r /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory
      [entpnerd@myhost ~]$ rm -r /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      [entpnerd@myhost ~]$ rm -rd /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      [entpnerd@myhost ~]$ sudo rm -rd /data/sharedlogs/otherhost/vcs
      rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory
      
    3. inode ID: I tried removing by the inode (as suggested by this answer to a similar question), but I had no luck with that either, because as you can see from the output of the above ls command, the vcs directory has no inode ID.
    4. Non-ASCII characters: In the post, "How to Delete the Undeletable Directory", the directory had non-ASCII characters. This also is not the case as I saw from the xxd output:

      [entpnerd@myhost ~]$ ls -l /data/sharedlogs/otherhost/ | xxd
      ls: cannot access /data/sharedlogs/otherhost/vcs: Not a directory
      0000000: 746f 7461 6c20 340a 6472 7778 722d 7872  total 4.drwxr-xr
      ...
      0000040: 3f3f 3f3f 3f20 3f20 3f20 2020 203f 2020  ????? ? ?    ?  
      0000050: 2020 2020 203f 2020 2020 2020 2020 2020       ?          
      0000060: 2020 3f20 7663 730a                        ? vcs.
      
    5. lsattr: As suggested by the similar question, "Why can't I delete this file as root?", I tried using the lsattr command, but with no luck either:

      [entpnerd@myhost ~]$ lsattr /data/sharedlogs/otherhost/
      -------------e-- /data/sharedlogs/otherhost/tkr
      /data/sharedlogs/otherhost/vcs: Not a directory
      [entpnerd@myhost ~]$ lsattr /data/sharedlogs/otherhost/vcs
      lsattr: Not a directory while trying to stat /data/sharedlogs/otherhost/vcs
      [entpnerd@myhost ~]$ sudo lsattr /data/sharedlogs/otherhost/vcs
      [sudo] password for entpnerd: 
      lsattr: Not a directory while trying to stat /data/sharedlogs/otherhost/vcs
      
    6. Setting executable bits for the directory: As per the similar question, "Question marks showing in ls of directory. IO errors too", I tried to set the executable bits for the directory, but no luck with that either.

      [entpnerd@myhost ~]$ sudo chmod -R g+x /data/sharedlogs/otherhost/vcs
      [sudo] password for entpnerd: 
      chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      [entpnerd@myhost ~]$ sudo chmod -R u+x /data/sharedlogs/otherhost/vcs
      chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      [entpnerd@myhost ~]$ sudo chmod -R a+x /data/sharedlogs/otherhost/vcs
      chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory
      

    Any help would be greatly appreciated.

    • Jaroslav Kucera
      Jaroslav Kucera over 6 years
      Is it mountpoint for unreachable remote filesystem (like NFS) or for local unreachable storage (either failed disk or FC storage)?
    • DocSalvager
      DocSalvager over 6 years
      Is this the same as serverfault.com/q/65616/208710
  • kasperd
    kasperd over 5 years
    That sounds very unlikely.
  • abettermap
    abettermap over 5 years
    Worked for me on Windows WSL with Ubuntu 16.04.
  • entpnerd
    entpnerd over 5 years
    Thanks for your answer @GM83. Did you actually manage to fix the directory or did you just remove the directory with the fusermount -u command?
  • halra
    halra almost 4 years
    This works in cases where the file is mounted into a container. Restarting Docker releases the mount.