LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-09-2015, 04:45 AM   #1
oxykasper
LQ Newbie
 
Registered: May 2015
Location: Yorkshire, UK
Distribution: Debian wheezy
Posts: 22

Rep: Reputation: Disabled
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.
 
Old 07-09-2015, 06:43 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.

Last edited by rtmistler; 07-09-2015 at 06:49 AM.
 
Old 07-09-2015, 06:54 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
before executing rm you can try lsof and fuser to find out if a process is using that file
 
1 members found this post helpful.
Old 07-09-2015, 07:00 AM   #4
oxykasper
LQ Newbie
 
Registered: May 2015
Location: Yorkshire, UK
Distribution: Debian wheezy
Posts: 22

Original Poster
Rep: Reputation: Disabled
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?
 
Old 07-09-2015, 07:02 AM   #5
oxykasper
LQ Newbie
 
Registered: May 2015
Location: Yorkshire, UK
Distribution: Debian wheezy
Posts: 22

Original Poster
Rep: Reputation: Disabled
(Reply was to rtmistler)

Will try what pan64 suggests.
 
Old 07-09-2015, 07:05 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 07-11-2015, 01:19 PM   #7
Archy1
Member
 
Registered: Jan 2014
Distribution: Debian
Posts: 95

Rep: Reputation: 2
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!

Last edited by Archy1; 07-11-2015 at 01:20 PM.
 
Old 07-11-2015, 01:42 PM   #8
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
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

Last edited by John VV; 07-11-2015 at 01:44 PM.
 
Old 07-11-2015, 08:56 PM   #9
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by oxykasper View Post
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?

Last edited by berndbausch; 07-12-2015 at 01:21 AM.
 
Old 07-11-2015, 09:55 PM   #10
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting soft links They won't go away zeelog Slackware 2 08-09-2009 11:34 AM
Deleting files rossi46 Mandriva 5 11-08-2006 08:15 AM
Deleting files in C monil Programming 4 03-13-2005 10:33 AM
Samba deleting links schoeppchen Linux - Enterprise 1 03-04-2005 05:22 PM
deleting orphan files and creating soft links cuss Linux - General 6 02-24-2003 09:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration