Why does `rm -rf`` silently fail?

0

[EDIT] Please don't waste your time reading my question below. It turns out my colleague is an idiot.. :)

On my server I'm trying to remove a folder and all its subfolders with the usual rm -rf dirname, but it silently fails:

kramer65@vps1:~$ ls -l
total 24
drwxrwxr-x  2 kramer65 kramer65 4096 Jul 11 22:00 backups
drwxrwxr-x  2 kramer65 kramer65 4096 Jul 17 17:37 bin
drwxrwxr-x  3 kramer65 kramer65 4096 Sep  1 11:11 cxs
kramer65@vps1:~$ rm -rf cxs/
kramer65@vps1:~$ ls
backups  bin  cxs
kramer65@vps1:~$ sudo rm -rf cxs/
kramer65@vps1:~$ ls
backups  bin  cxs
kramer65@vps1:~$ rmdir cxs/
rmdir: failed to remove ‘cxs/’: Directory not empty

I also tried removing all contents of the dir:

kramer65@vps1:~$ cd cxs
kramer65@vps1:~/cxs$ ls
app            README.md
kramer65@vps1:~/cxs$ rm -rf *
kramer65@vps1:~/cxs$ ls
app            README.md
kramer65@vps1:~/cxs$ sudo rm -rf *
kramer65@vps1:~/cxs$ ls
app            README.md

I'm okay with failing commands, if only it would tell me whats wrong. Any idea what I'm doing wrong here? All tips are welcome!

[EDIT] I tried the following (also to no avail):

kramer65@vps1:~$ sudo rm -vrf cxs/*
removed ‘cxs/app/static/img/face1.jpg’
removed ‘cxs/app/static/img/face2.jpg’
removed ‘cxs/app/static/img/face3.jpg’
[etc.etc.]
removed directory: ‘cxs/app’
removed ‘cxs/README.md’
kramer65@vps1:~$ ls cxs/
app            README.md
kramer65@vps1:~$

[EDIT2] Turns out a colleague had an rsync running which constantly re-wrote the files to that folder. So it did remove them, but it automatically re-created them again as well. (I'm banging my head against the wall here!)

kramer65

Posted 2014-09-01T09:20:06.537

Reputation: 1 335

Have you tried going back a directory and running sudo rm -rf /cxc/* – Matthew Williams – 2014-09-01T09:27:02.323

@MatthewWilliams - Just tried that, to no avail.. :S – kramer65 – 2014-09-01T09:28:52.517

Try running sudo rm -vf /cxc/* and see what it dumps out – Matthew Williams – 2014-09-01T09:30:12.497

@MatthewWilliams - I ran it, checkout my updated question. – kramer65 – 2014-09-01T09:35:29.790

At least you know your rsync is working correctly ;) – Matthew Williams – 2014-09-01T09:50:15.157

Answers

2

Try the following

rm -rf /the/full/dir

Roemer Bakker

Posted 2014-09-01T09:20:06.537

Reputation: 167

I tried that, but it again results in a silent fail.. – kramer65 – 2014-09-01T09:29:58.763

@kramer65 Are you sure you have the right permissions? – Roemer Bakker – 2014-09-01T09:32:00.843

Well, I'm owner, and I tried using sudo, plus it doesn't say anything about permissions, so I wouldn't know why that would be the problem.. – kramer65 – 2014-09-01T09:36:44.597

Try @garethTheRed 's answer. That might work – Roemer Bakker – 2014-09-01T09:41:25.870

2Turns out my colleague constantly synced those files from his computer to the server. Thanks for your help anyway! – kramer65 – 2014-09-01T09:41:56.373

Ha! Yes, such things happen ;) You're welcome! – Roemer Bakker – 2014-09-01T09:46:41.053

1

Check the extended attributes for the files:

lsattr -R /cxs

If any have the i attribute set then it's immutable, meaning it can't be deleted.

Remove the immutable attribute with:

chattr -i <path to file/directory>

Then try to delete again.

Note that a file with the immutable attribute set doesn't normally fail silently when you try to delete it but instead complains of 'Operation not permitted'.

garethTheRed

Posted 2014-09-01T09:20:06.537

Reputation: 2 520

Turns out my colleague constantly synced those files from his computer to the server. Thanks for your help anyway! – kramer65 – 2014-09-01T09:41:37.857

Colleague!!!??? Go and slap him/her ;-) – garethTheRed – 2014-09-01T09:44:50.370