How can I delete a file with permission 444?

My server is running Ubuntu 18.04.

I have a file in vestacp that I cannot delete. This file contains malware and has permission 444 and when I try to delete it using sudo rm -rf file or even change permissions using sudo chmod 777 it just does nothing.

I also cannot edit the file at all. I even changed ownership using chown admin:admin but nothing is happening.

5

4 Answers

Ideas:

  1. some process may use the file, with lsof you can look, which process has it locked:
$ lsof | grep vestacp

If you see the process, you should kill it first and then try to delete the file.

  1. Reboot, choose in grub menu recovery option and try to delete the file.
1

There is no admin in linux. The user you're looking for is root.

Locally root may do everything technically possible. You can even delete your whole filesystem including your operating system. So be careful!

So as long as you're in the context of user root it's no issue to delete a local file you don't have any permissions to.

Just do:

rm YOURFILE
1

I have encountered a issue like this a long time ago and this commands below helped

without super user privileges ls file_to_be_delete | xargs /bin/rm --force

With super user privileges ls file_to_be_delete | sudo xargs /bin/rm --force

1

I tried all the answers above, though promising and well researched, none seemed to stick for long. I finally resolved to changing the ownership of these files to root using chown -R root:root folder or without -R for a file. This then makes editing difficult for any user, including admin which was the main problem. Now for me to make any changes, I either use terminal or change the ownership to admin after that I return it to root.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like