我在Ubuntu中通过按照这个步骤创建了一个交换文件,但我现在不再需要它,所以我想删除它。
然而,这篇博文没有提及关于删除的任何内容,所以我尝试使用sudo rm -rf
进行删除,但出现了Operation not permitted
错误。
到目前为止,我尝试了许多解决由相同错误导致无法删除文件的方法,但对我的情况都没有起作用:
- https://unix.stackexchange.com/questions/370255/as-root-cannot-remove-file-under-tmp-operation-not-permitted
- 更改所有权:“操作不允许”-即使是root!
- https://unix.stackexchange.com/questions/29902/unable-to-delete-file-even-when-running-as-root
,其中包括:
- 更改交换文件和根目录
/
的权限(hmod ugo+w .
) - 在交换文件和
/
上更改不可变标志(chattr -i -a .
) - 重新启动系统
所有这些都没有起作用。我想知道如何删除它,但如果它是一个交换文件,我该如何删除它?
free -h
的结果是:
total used free shared buff/cache available
Mem: 1.7G 101M 405M 1.2M 1.2G 1.4G
Swap: 1.5G 234M 1.3G
free -h
并将结果附加到您的问题中。 - Charles Greensudo swapoff -a
,然后尝试删除交换文件。 - Charles Green