我使用 Ubuntu Studio 18.04.2 LTS(64 位 Linux)。
在我使用的一台装有该操作系统的电脑上,我发现了一个问题:有一个文件夹,系统拒绝删除,因为根据系统的说法,它不是空的。
但是...该文件夹是空的!!!
我使用完全sudo
权限和命令进行了测试rm -f
,但是...无论何时我要求,系统都拒绝删除该文件夹。
我知道的任何用于查看该文件夹内是否有某个文件的命令都会显示该文件夹是空的。
该命令的输出ls -la /path/to/folder
是:
total 56
drwxrwxrwx 1 root root 4096 ago 16 2016 .
drwxrwxrwx 1 root root 4096 ene 15 2016 ..
drwxrwxrwx 1 root root 49152 ene 15 2016 'Noemí paredes cyrus o'
在这种情况下我们能做什么?
还有其他方法可以删除该文件夹吗?
我认为我找到了原因,因为这里存在这个问题(我不知道这是否应该写成官方答案):
HDD 文件表存在问题(这是旧的 MS-Windows NTFS 磁盘分区)。我发现这个问题是因为我曾经gparted
尝试修复 HDD 可能存在的任何问题,并且...工具verify
告诉我文件表中存在许多不一致之处。
GParted 0.30.0 --enable-libparted-dmraid --enable-online-resize
Libparted 3.2
Verificar y reparar el sistema de archivos (ntfs) en /dev/sdb1 00:00:09 ( ERROR )
calibrar /dev/sdb1 00:00:00 ( ÉXITO )
ruta: /dev/sdb1 (partición)
inicio: 63
fin: 976767119
tamaño: 976767057 (465.76 GiB)
comprobar errores en el sistema de archivos en /dev/sdb1 y (si es posible) arreglarlos 00:00:09 ( ERROR )
ntfsresize -i -f -v '/dev/sdb1' 00:00:09 ( ERROR )
ntfsresize v2017.3.23 (libntfs-3g)
Device name : /dev/sdb1
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 500104733184 bytes (500105 MB)
Current device size: 500104733184 bytes (500105 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Cluster 19313449 is referenced multiple times!
Cluster 116319777 is referenced multiple times!
Cluster 116319778 is referenced multiple times!
Cluster 116319779 is referenced multiple times!
Cluster 116319780 is referenced multiple times!
Cluster 116319781 is referenced multiple times!
Cluster 116319782 is referenced multiple times!
Cluster 116319783 is referenced multiple times!
Cluster 116319784 is referenced multiple times!
Cluster 116319785 is referenced multiple times!
Cluster 116319964 is referenced multiple times!
Cluster 116319965 is referenced multiple times!
Cluster 116319966 is referenced multiple times!
Cluster 116319967 is referenced multiple times!
Cluster 116319968 is referenced multiple times!
Cluster 116319969 is referenced multiple times!
Cluster 116319970 is referenced multiple times!
Cluster 116319971 is referenced multiple times!
Cluster 116319972 is referenced multiple times!
Cluster 116319973 is referenced multiple times!
Cluster 116319974 is referenced multiple times!
Cluster 116319975 is referenced multiple times!
Cluster 116319976 is referenced multiple times!
Cluster 116319977 is referenced multiple times!
Cluster 116319978 is referenced multiple times!
Cluster 116319979 is referenced multiple times!
Cluster 116319980 is referenced multiple times!
Cluster 116319981 is referenced multiple times!
Cluster 116319982 is referenced multiple times!
Cluster 116319983 is referenced multiple times!
Cluster 116319984 is referenced multiple times!
Cluster 116319985 is referenced multiple times!
Cluster 116319986 is referenced multiple times!
Cluster 116319987 is referenced multiple times!
Cluster 116319988 is referenced multiple times!
Cluster 116319989 is referenced multiple times!
Cluster 116319990 is referenced multiple times!
Cluster 116319991 is referenced multiple times!
Cluster 116319992 is referenced multiple times!
Cluster 116319993 is referenced multiple times!
Cluster 116319994 is referenced multiple times!
Cluster 116319995 is referenced multiple times!
Cluster 116319996 is referenced multiple times!
Cluster 116319997 is referenced multiple times!
Cluster 116319998 is referenced multiple times!
Cluster 116319999 is referenced multiple times!
Cluster 116320000 is referenced multiple times!
Cluster 116320001 is referenced multiple times!
Cluster 116320002 is referenced multiple times!
Cluster 116320003 is referenced multiple times!
Cluster 116320004 is referenced multiple times!
Cluster 116320005 is referenced multiple times!
Cluster 116320006 is referenced multiple times!
Cluster 116321070 is referenced multiple times!
Cluster 116321071 is referenced multiple times!
Cluster 116321072 is referenced multiple times!
Cluster 116321073 is referenced multiple times!
Cluster 116321074 is referenced multiple times!
Cluster 116321075 is referenced multiple times!
Cluster 116321076 is referenced multiple times!
Cluster 116321077 is referenced multiple times!
Cluster 116321078 is referenced multiple times!
Cluster 116321079 is referenced multiple times!
Cluster 116321080 is referenced multiple times!
Cluster 116321081 is referenced multiple times!
Cluster 116321082 is referenced multiple times!
Cluster 116321083 is referenced multiple times!
Cluster 116321084 is referenced multiple times!
Cluster 116321085 is referenced multiple times!
Cluster 116321086 is referenced multiple times!
Cluster 116321087 is referenced multiple times!
Cluster 116321088 is referenced multiple times!
Cluster 116321089 is referenced multiple times!
Cluster 116321090 is referenced multiple times!
Cluster 116321091 is referenced multiple times!
Cluster 116321092 is referenced multiple times!
Cluster 116321093 is referenced multiple times!
Cluster 116321094 is referenced multiple times!
Cluster 116321095 is referenced multiple times!
Cluster 116321096 is referenced multiple times!
Cluster 116321097 is referenced multiple times!
Cluster 116321098 is referenced multiple times!
Cluster 116321099 is referenced multiple times!
Cluster 116321100 is referenced multiple times!
Cluster 116321101 is referenced multiple times!
Cluster 116321102 is referenced multiple times!
Cluster 116321103 is referenced multiple times!
Cluster 116321104 is referenced multiple times!
Cluster 116321105 is referenced multiple times!
Cluster 116321106 is referenced multiple times!
Cluster 116321107 is referenced multiple times!
Cluster 116321108 is referenced multiple times!
Cluster 116321109 is referenced multiple times!
Cluster 116321110 is referenced multiple times!
Cluster 116321111 is referenced multiple times!
Cluster 116321112 is referenced multiple times!
Cluster 116321113 is referenced multiple times!
Cluster 116321114 is referenced multiple times!
Cluster 116321115 is referenced multiple times!
Cluster 116321116 is referenced multiple times!
Cluster 116321117 is referenced multiple times!
Cluster 116321118 is referenced multiple times!
Cluster 116321119 is referenced multiple times!
Cluster 116321120 is referenced multiple times!
Cluster 116321121 is referenced multiple times!
Cluster 116321122 is referenced multiple times!
Cluster 116321123 is referenced multiple times!
Cluster 116321124 is referenced multiple times!
Cluster 116321125 is referenced multiple times!
Cluster 116321126 is referenced multiple times!
Cluster 116321127 is referenced multiple times!
Cluster 116321128 is referenced multiple times!
Cluster 116321129 is referenced multiple times!
Cluster 116321130 is referenced multiple times!
Cluster 116321131 is referenced multiple times!
Cluster 116321132 is referenced multiple times!
Cluster 116321133 is referenced multiple times!
Cluster 116321134 is referenced multiple times!
Cluster 116321135 is referenced multiple times!
Cluster 116321136 is referenced multiple times!
Cluster 116321137 is referenced multiple times!
Cluster 116321138 is referenced multiple times!
Cluster 116321139 is referenced multiple times!
Cluster 116321140 is referenced multiple times!
Cluster 116321141 is referenced multiple times!
Cluster 116321142 is referenced multiple times!
100.00 percent completed
ERROR: Filesystem check failed!
ERROR: 126 clusters are referenced multiple times.
NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE!
The usage of the /f parameter is very IMPORTANT! No modification was
and will be made to NTFS by this software until it gets repaired.
不幸的是,我这里没有安装 MS-Windows 的设备。有没有什么 Linux 工具可以解决这个问题?
答案1
如果您想要删除目录,则需要使用-r
rm 标志。
例如:
rm -r 目录
来自 rm 手册页:
-r, -R, --recursive remove directories and their contents recursively
答案2
您可以使用:
rmdir --ignore-fail-on-non-empty folder1/
额外:如果您想控制要删除的子目录,而不想只是递归删除,则使用标志将删除嵌套目录,与创建嵌套目录-p
相反。mkdir -p folder1/folder2/
答案3
尝试:
rmdir /directory/sub-directory/sub-sub-directory
或者更好的是:
cd /one/level/above/directory/
rmdir sub-directory
另外,在您的问题中,最好复制并粘贴您的屏幕输出,其中包含输入的命令和系统报告的错误消息(如果有)。额外的好处是发布的答案可以使用真实的目录名称,而不是虚构的目录名称。