LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Deleting files with zero links (https://www.linuxquestions.org/questions/linux-general-1/deleting-files-with-zero-links-4175547580/)

oxykasper 07-09-2015 04:45 AM

Deleting files with zero links
 
I have a large (hundreds, not thousands) number of files which I cannot delete, for example

49504 -rwxr-xr-x 0 root root 50691712 Sep 26 2009 5 - Arensky: Variations on a theme of Tchaikovsky, Op 35A.flac

rm -rf does nothing at all, and gives no error message.

I have tried mv to get it somewhere else and this just produces

mv: cannot stat `....': No such file or directory

Using Nautilus produces similar error messages.

My *guess* is that the problem is the 0 links, but I cannot find how to
change this.

What I've been doing: I have needed to delete about 330GB of flac files to free up space before replacing with a better version. I used rm -r successfully on most directories (most have about 6 levels of sub-dirs) but am stuck with a few dirs containing scattered files like the above.

Using debian wheezy. The files are actually mounted from a NAS, so am working as root.

If you can confirm/correct my guess and point me to information that would be great. Looking at info chmod and info ls hasn't helped.

rtmistler 07-09-2015 06:43 AM

The file shown is owned by root, have you been logged in as root and trying to delete it? How about using:
Code:

sudo rm -f <filename>
And BE CAREFUL about using root or sudo and then issuing commands such as -rf and using wildcards *, because the very old and very BAD joke was to tell someone to issue a command designed to remove their entire file system. I shall not repeat that command for your pleasure.

If you login to your XWindows as a normal user, then you really can't use Nautilus to do this. An alternate way I'd say would be to so something better like this from a top level directory where these files start from:
Code:

sudo chown -R <your-user-name> *
sudo chgrp -R <your-user-group> *

What that does is changes all the files, and directories which contain them to be owned by your username and placed into the same group that your username is. And then you can access these files properly from things like Nautilus and perform the file removal.

pan64 07-09-2015 06:54 AM

before executing rm you can try lsof and fuser to find out if a process is using that file

oxykasper 07-09-2015 07:00 AM

Yes, I've got that thanks. I am working as root.

I did make slips in mistranscribing the commands.

I've tried to delete dirs :
<code>
ls -lsa
0 drwxr-xr-x 0 root root 0 Jul 9 09:41 ARENSKY
root@TQD:/mnt/M-Multimedia# rm -rf ARENSKY/
rm: cannot remove `ARENSKY/ULSTER_O/Variations on a theme of Tchaikovsky, Op.35a': Directory not empty
root@TQD:/mnt/M-Multimedia#
</code>

The only file in this dir (two levels down) is
<code>
49504 -rwxr-xr-x 0 root root 50691712 Sep 26 2009 5 - Arensky: Variations on a theme of Tchaikovsky, Op 35A.flac
</code>
and doing rm -f on this leaves the file intact and issues no error message.

Maybe the zero links is not the problem?

oxykasper 07-09-2015 07:02 AM

(Reply was to rtmistler)

Will try what pan64 suggests.

rtmistler 07-09-2015 07:05 AM

I don't suggest you work as root given that you have some trouble with these types of command.

You really can get yourself into critical system trouble a.k.a. destroy your entire system, if you issue a misplaced rm -rf command.

Archy1 07-11-2015 01:19 PM

I don't know anything about this subject but I just read this thread and it may be relevant to your situation:
https://www.linuxquestions.org/quest...nd-4175547602/
EDIT: LOLOLOL SORRY! Didn't know that was your post as well!

John VV 07-11-2015 01:42 PM

that "bomb" of a command can be VERY EASILY created from a
NORMAL!! EVERYDAY!!!! TYPO!!!! that we all make EVERY DAY

so heed the warning

rm and r and f
DO NOT MIX WELL


on Debian systems "srm" is likley installed or in the repos

on RPM systems the debian srm source code builds JUST FINE


for normal recursive removal of files a "simple" zero pass is fine and quick


also this file name
Quote:

5 - Arensky: Variations on a theme of Tchaikovsky, Op 35A.flac
that is a issue

berndbausch 07-11-2015 08:56 PM

Quote:

Originally Posted by oxykasper (Post 5389224)
Code:

ls -lsa
0 drwxr-xr-x 0 root root 0 Jul  9 09:41 ARENSKY
root@TQD:/mnt/M-Multimedia# rm -rf ARENSKY/
rm: cannot remove `ARENSKY/ULSTER_O/Variations on a theme of Tchaikovsky, Op.35a': Directory not empty
root@TQD:/mnt/M-Multimedia#

The only file in this dir (two levels down) is
Code:

49504 -rwxr-xr-x 0 root root 50691712 Sep 26  2009 5 - Arensky: Variations on a theme of Tchaikovsky, Op 35A.flac
and doing rm -f on this leaves the file intact and issues no error message.

Maybe the zero links is not the problem?

A file with a name can't have zero links. In other words, a name is a link. In other words, something's fishy.

Go to the ARENSKY directory and, using ls -a, check if the dot and dotdot files are there (they are named "." and "..", respectively). If not, something's even more fishy.
Can you unmount this filesystem and fsck it?
If not, can you boot a live CD and fsck this filesystem?

Doug G 07-11-2015 09:55 PM

Try using midnight commander. mc has been able to delete some otherwise un-deleteable files for me.

Also mc is a bit more fail-safe than the command line when deleting directory trees.


All times are GMT -5. The time now is 10:38 PM.