Ubuntu rm not deleting files

rmUbuntu

My colleague and I have been struggling with deleting a directory and its contents.

We are working on a new version of our websites source code on Ubuntu 8.04 (dir: /var/www/websites), what we want to do is delete the websites directory and recreate it from a .tar backup we created a couple weeks ago. The purpose of this is so we can run our deployment procedure in a local environment before we do so on our live / public environment.

We use this command:

rm -r websites

This deletes the directory and the files within it.

The problem occurs when we un-tar our backup file and view the website we are getting files that don't exist in the .tar backup, in fact these files were only created a few days ago and should have been deleted.

We delete the directory once more in the manner stated above, we then create a new websites directory using the mkdir command. Strangely at this stage the 'deleted files' do not come back, but if we unpack our .tar file the 'deleted files' appear again.

Is there a way to ensure these files are deleted, or at least the pointers that associate them with said directory.

  • Our .tar backup does not include these files
  • We do not want to use the shred command
  • We do not want to use 3rd party applications
  • Solution should be functional via terminal (SSH)

Many thanks!

EDIT

Er… we fixed it. Turns out the files that are reappearing are because of a link we have to another directory (outside the /var/www/websites), we were restoring the link but not deleting the files on the other end. D'oh!

Many thanks for your help guys… friday afternoon syndrome 🙂

Best Answer

I think something is either recreating the files, and you have to identify that (check the cron log maybe?), or the files really are in your tar file.

To check if it is in the tar file:

tar tvf tarfile.tar | grep 'nameOfReappearingFile'
tar tvzf tarfile.tar.gz | grep 'nameOfReappearingFile'
tar tzjf tarfile.tar.bz2 | grep 'nameOfReappearingFile'

To hunt for cron jobs, see this Serverfault Post: How to View All Cron Jobs On Linux?. You could also run top to watch if there any processes when you see the files start to be recreated.