简体   繁体   English

Linux:如何删除锁定的文件

[英]Linux : How to delete locked file

I want to remove xyz_DB.lock.db file . 我想删除xyz_DB.lock.db file I tried as root but couldn't delete it. 我尝试以root用户身份登录,但无法将其删除。 How to remove it in terminal. 如何在终端中删除它。 My initial requirement was remove a folder. 我最初的要求是删除一个文件夹。 but it includes this locked file. 但它包含此锁定的文件。 And is there anyway to delete folder directly which include a locked file ? 而且有直接删除包含锁定文件的文件夹吗?

Check with lsattr command if the immutable bit is set for the file, it will show (i) 使用lsattr命令检查是否为文件设置了不可变位,它将显示(i)

# lsattr file
----i--------e- file

If so, change it using following command: 如果是这样,请使用以下命令进行更改:

# chattr -i file

And then try to remove it. 然后尝试将其删除。

尝试通过GUI更改文件许可权,或在包含该许可权的目录上使用rm -rf。

try "chown" to provide permission to your file/folder and then delete it, 尝试“ chown”为您的文件/文件夹提供权限,然后将其删除,

eg: assume username= amol and filename=myfile.txt,, 例如:假设用户名= amol,文件名= myfile.txt,

For File:--- sudo chown amol:amol myfile.txt 对于文件:--- sudo chown amol:amol myfile.txt

For Folder:-- sudo chown -R amol:amol directory_name 对于文件夹:-sudo chown -R amol:amol directory_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM