Malintha
Malintha

Reputation: 4776

Linux : How to delete locked file

I want to remove xyz_DB.lock.db file. I tried as root but couldn't delete it. 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 ?

Upvotes: 1

Views: 9401

Answers (3)

ronask
ronask

Reputation: 11

Check with lsattr command if the immutable bit is set for the file, it will show (i)

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

If so, change it using following command:

# chattr -i file

And then try to remove it.

Upvotes: 1

user3778735
user3778735

Reputation: 1

try "chown" to provide permission to your file/folder and then delete it,

e.g: assume username= amol and filename=myfile.txt,,

For File:--- sudo chown amol:amol myfile.txt

For Folder:-- sudo chown -R amol:amol directory_name

Upvotes: 0

James Hunt
James Hunt

Reputation: 2528

Try either changing the files permissions through the GUI or use rm -rf on the directory that contains it.

Upvotes: 0

Related Questions