ent*_*erd 5 linux ls file-permissions rm centos7
我正在使用 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
Run Code Online (Sandbox Code Playgroud)
输出表明我的目录vcs“不是目录”,即使它应该是,因为这是以前记录文件的位置。此外,文件权限位现在都是问号,所有者和(莫名其妙)inode ID 也是问号。
如何让文件系统再次将我的目录识别为目录?
在尝试了我在下面概述的所有内容后,我看到的唯一前进路径是确保备份并运行磁盘fsck(如本论坛建议的那样),或者可能只是格式化整个安装。希望我能找到一个更简单、不那么激烈的解决方案。
我尝试过的一些事情:
sudo: 我试过运行,sudo ls但输出没有区别。rm: 我试着移除vcs把它放回去,但没有运气。我在有sudo和没有的情况下都尝试过,但也没有运气。奇怪的是,当我尝试时,sudo rm它指出Is a directory. 我也试过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
Run Code Online (Sandbox Code Playgroud)ls命令的输出中可以看出,该vcs目录没有 inode ID。非 ASCII 字符:在帖子“如何删除不可删除的目录”中,该目录具有非 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.
Run Code Online (Sandbox Code Playgroud)lsattr:正如类似问题所建议的,“为什么我不能以 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
Run Code Online (Sandbox Code Playgroud)为目录设置可执行位:根据类似的问题,“在目录的 ls 中显示问号。IO 错误也是”,我尝试为目录设置可执行位,但也没有运气。
[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
Run Code Online (Sandbox Code Playgroud)任何帮助将不胜感激。
小智 1
这可能是安装服务(例如 Samba)的问题。尝试在远程主机上重新启动 Samba 服务:
sudo service smb restart
Run Code Online (Sandbox Code Playgroud)