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.
4 Answers
Ideas:
- some process may use the file, with
lsofyou can look, which process has it locked:
$ lsof | grep vestacpIf you see the process, you should kill it first and then try to delete the file.
- Reboot, choose in grub menu recovery option and try to delete the file.
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:
1rm YOURFILE
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
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.