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.

3
  • Are you the root user?
    – atx
    Mar 1, 2011 at 19:28
  • What does ls -lZ old/etc/rc.d/init.d/functions say? lsattr old/etc/rc.d/init.d/functions?
    – DerfK
    Mar 1, 2011 at 19:45
  • ls -lZ old/etc/rc.d/init.d/functions -rwxr-xr-x root root old/etc/rc.d/init.d/functions
    – Jay
    Mar 2, 2011 at 18:23

2 Answers 2

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
3
  • 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 2, 2011 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 2, 2011 at 18:43
  • Thanks Iain - I just removed the ----a------ also which was causing the file to be un-deletable!
    – Jay
    Mar 3, 2011 at 6: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 
2
  • What should I set the permissions to?
    – Jay
    Mar 1, 2011 at 19:34
  • See my edit, this is a real broad sweep, but should help. Be real careful though that you only affect the old directory.
    – Sven
    Mar 1, 2011 at 19:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .