![如何删除可以看到但没有程序可以触及的文件?](https://linux22.com/image/69097/%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4%E5%8F%AF%E4%BB%A5%E7%9C%8B%E5%88%B0%E4%BD%86%E6%B2%A1%E6%9C%89%E7%A8%8B%E5%BA%8F%E5%8F%AF%E4%BB%A5%E8%A7%A6%E5%8F%8A%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%9F.png)
我正在尝试删除一些过时的备份,在其中的深处我发现了一个文件“cifs3bee”,但我找不到删除的方法。 (因为我无法删除它,所以它阻止删除通向它的整个目录树。)如果我运行ls -l
我得到:
total 1
-rwxr-xr-x 1 jgw87 root 307 Oct 30 2014 cifs3bee
如果我跑步,file cifs3bee
我有时会得到:
cifs3bee: writable, regular file, no read permission
但有时我会得到:
cifs3bee: ERROR: cannot open `cifs3bee' (No such file or directory)
如果我运行 rm、chmod、lsattr、less 或任何其他命令(即使我 sudo 到 root),这基本上与我总是得到的错误相同。我什至尝试了“ echo "x" > cifs3bee
”,但仍然收到No such file or directory
错误,即使ls
将继续显示文件,并且rm -rf
父目录上的“ ”失败,表示该目录不为空。
这是怎么回事,有人知道如何解决这个问题吗?我什至不知道这个文件是如何进入我的备份的,因为该名称与我为要抓取的文件设置的模式不匹配。
编辑:抱歉,忘记了系统规格。这是我运行的 Linux Mint 17,在通过 Samba 安装的远程 Windows 服务器上工作。 (我不知道服务器规格。)
编辑:我跑了strace head cifs3bee
,输出如下:
execve("/usr/bin/head", ["head", "cifs3bee"], [/* 69 vars */]) = 0
brk(0) = 0x11f0000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ccbe8f000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-5.0/lib/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-5.0/lib/tls/x86_64", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-5.0/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-5.0/lib/tls", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-5.0/lib/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-5.0/lib/x86_64", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-5.0/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-5.0/lib", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/home/jgw87/Software/root/lib/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/jgw87/Software/root/lib/tls/x86_64", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/home/jgw87/Software/root/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/jgw87/Software/root/lib/tls", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/home/jgw87/Software/root/lib/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/jgw87/Software/root/lib/x86_64", 0x7fff275aa470) = -1 ENOENT (No such file or directory)
open("/home/jgw87/Software/root/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/jgw87/Software/root/lib", {st_mode=S_IFDIR|0770, st_size=32768, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=168641, ...}) = 0
mmap(NULL, 168641, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8ccbe65000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8ccb8aa000
mprotect(0x7f8ccba65000, 2093056, PROT_NONE) = 0
mmap(0x7f8ccbc64000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7f8ccbc64000
mmap(0x7f8ccbc6a000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8ccbc6a000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ccbe64000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ccbe62000
arch_prctl(ARCH_SET_FS, 0x7f8ccbe62740) = 0
mprotect(0x7f8ccbc64000, 16384, PROT_READ) = 0
mprotect(0x608000, 4096, PROT_READ) = 0
mprotect(0x7f8ccbe91000, 4096, PROT_READ) = 0
munmap(0x7f8ccbe65000, 168641) = 0
brk(0) = 0x11f0000
brk(0x1211000) = 0x1211000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2919792, ...}) = 0
mmap(NULL, 2919792, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8ccb5e1000
close(3) = 0
open("cifs3bee", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ccbe8e000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2570
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7f8ccbe8e000, 4096) = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=619, ...}) = 0
mmap(NULL, 619, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8ccbe8e000
close(3) = 0
open("/usr/lib/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "head: ", 6head: ) = 6
write(2, "cannot open \342\200\230cifs3bee\342\200\231 for r"..., 38cannot open ‘cifs3bee’ for reading) = 38
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(1) = ?
+++ exited with 1 +++
不幸的是,我不知道如何解释这一点。有什么帮助吗?
答案1
首先,我想知道文件名上是否有尾随空格。通过键入ls "cifs
然后按 Tab 键自动完成进行测试(假设您使用的是 Linux 机器,这当然是一个很大的假设)。如果这没有效果,请尝试删除该文件inode
。
这里很好地解释了如何执行此操作:删除/移除带有 inode 号的文件
该过程的重点包括
首先获取文件的索引节点:ls -il
然后使用手中的索引节点尝试删除该文件:
find . -inum [inode-number] -exec rm -i {} \;</b>
答案2
您仍然可以在其分区周围移动该文件。尝试将其移开。但似乎是磁盘或文件系统错误。我要做的下一步是 fsck 。
另外,尝试'strace echo“abcd”> file'并找出哪个系统调用真正生成错误,例如“没有这样的文件或目录”,因为如果它不存在,则应该创建它,所以其他东西不存在,例如bash解释器或父目录或者 echo 不是 echo 而是别名。
另一种可能性是,某些东西会删除/恢复文件,因此您不太幸运,它会在您查看文件的同时被删除并重新创建。
另一种可能性是文件系统特定的东西,因为其他人正确指出文件名中“cifs”的存在表明了这种可能性。