1

I am attempting to delete a backup directory on MediaTemple's (dv) via SSH. The directory is "old" and contains the entire server contents from OS level that (mt) backed up there after my server was hacked. I want to remove it in case there's any malware etc there that could compromise the server again. It is not permitting me though:

cannot remove `old/etc/rc.d/init.d/functions': Operation not permitted

I tried rebooting the server and retrying the delete but still same.

Jay
  • 13
  • 3

2 Answers2

2

If you are working as root and this happens then there may be extended attributes set on the file. Have a look at the output of

lsattr /old/rc.d/init.d/functions

if you get an output containing an i

----i-------- /old/rc.d/init.d/functions

then the file is imutable and cannot be deleted. To remove the i

chattr -i /old/rc.d/init.d/functions
user9517
  • 115,471
  • 20
  • 215
  • 297
  • Hey Iain, it did have an 'i' in the attributes, so I removed as you described but still would not permit deletion: `sattr old/etc/rc.d/init.d/functions` `-----a------- old/etc/rc.d/init.d/functions rm -rf old `rm: cannot remove `old/etc/rc.d/init.d/functions': Operation not `permitted ` – Jay Mar 02 '11 at 18:33
  • @Jay: check the `/old/rc.d/init.d` for the `i` flag and remove it if it's there. It may be an idea to run `chattr -R -i /old` – user9517 Mar 02 '11 at 18:43
  • Thanks Iain - I just removed the ----a------ also which was causing the file to be un-deletable! – Jay Mar 03 '11 at 06:28
1

I am assuming you are working as root? If so, try to explicitely set ownership and permissions for the whole tree and then try the delete again:

  chown -R root old
  chmod -R u+rwx old 
  rm -rf old 
Sven
  • 98,649
  • 14
  • 180
  • 226