linux – error message when trying to remove file

Question:

When I run the command

root@debian-hy:/var/www/sys# rm teste.txt
rm: cannot remove `teste.txt': Operation not permitted

Strange because I can edit the file and save, but when I close the vi it ​​generates a swap file, the file permissions follow:

-rwxrwxrwx  1 root root        6 May 21 08:31 teste.tx~
-rwxrwxrwx  1 root root      12K May 21 08:31 teste_tx.swn
-rwxrwxrwx  1 root root      12K May 21 08:31 teste_tx.swo
-rwxrwxrwx  1 root root     4.0K May 21 08:26 teste_tx.swp
-rwxrwxrwx  1 root root       12 May 21 08:31 teste.txt
-rwxrwxrwx  1 root root        0 May 21 08:26 .teste.txt.swp
-rwxrwxrwx  1 root root        0 May 21 08:26 .teste.txt.swx

Answer:

Run the operation with sudo: sudo rm teste.txt

If that doesn't work, perform the following operations:

sudo chown root teste.txt
sudo chmod 777 teste.txt
sudo rm teste.txt
Scroll to Top