Wednesday, September 23, 2015

Ubuntu rm not deleting files



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 :-)


Answer



The problem was a sym-link that none of use were intelligent enough to spot.



Not to worry :-)


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...