我正在使用CentOS 7并尝试列出目录的内容但不能.当我尝试列出内容时,我得到以下输出:
[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
输出声明我的目录vcs是“Not a directory”,即使它应该是,因为这是以前记录过文件的地方.此外,文件权限位现在都是问题标记,所有者也是,并且(莫名其妙地)inode ID.
如何让文件系统再次将我的目录识别为目录?
在尝试了下面概述的所有内容之后,我看到的唯一前进路径是确保磁盘备份并运行fsck(如this forum所示)或者可能只是格式化整个安装.希望我找到一个更简单,不那么激烈的解决方案.
我试过的一些事情:
> sudo:我试过运行sudo ls但输出没有差别.
> rm:我试过删除vcs把它放回去但没有运气.我用sudo和没有尝试过这个,但也没有运气.奇怪的是,当我尝试sudo rm时,它声明是一个目录.我也试过rm同时使用-r和-d开关,也没有运气.我从rm命令尝试获得的输出是:
[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
> inode ID:我尝试通过inode删除(如this answer to a similar question所示),但我也没有运气,因为从上面的ls命令的输出可以看出,vcs目录没有inode ID.
>非ASCII字符:在帖子“How to Delete the Undeletable Directory”中,目录具有非ASCII字符.我从xxd输出中看到的情况也不是这样:
[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.
> lsattr:正如类似问题“Why can’t I delete this file as root?”所示,我尝试使用lsattr命令,但没有运气:
[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
>为目录设置可执行位:根据类似的问题“Question marks showing in ls of directory. IO errors too”,我尝试设置目录的可执行位,但也没有运气.
[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
任何帮助将不胜感激.
解决方法
这可能是安装服务(例如Samba)的问题.尝试在远程主机上重新启动Samba服务:
sudo service smb restart