LinuxQuestions.org
Review your favorite Linux distribution.
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 10-31-2004, 03:33 PM   #1
elfoozo
Member
 
Registered: Feb 2004
Location: Washington, USA
Distribution: Debian
Posts: 265

Rep: Reputation: 32
Can't delete a file


Alright, I've been searching the forum all afternoon and I cannot find clues to help me resolve my problem....

I have a file showing up when I do ls -a | grep file_name but when I try to delete the file it tells me the file doesn't exist.

If I just do an ls file_name it tells me the file does NOT exist.

Based on ls -al I DO have owner and group permissions of the file. The files permission level is 664.

And when I do an ls -i file_name it DOES return an inode number.

If I dismount the drive and FORCE an e2fsck, it checks my entire disk and finds no errors.

If I try to force: rm -f file_name, it silently returns like it was deleted but ls -a | grep file_name still shows the file_name. Again, permissions are 664 with me as the owner & group. I get the same results when I do these same steps as root.

How can I delete this file that appears to have a valid inode but I can't see with a standard ls command?
 
Old 10-31-2004, 03:47 PM   #2
master
Member
 
Registered: Oct 2003
Location: Birmingham/Eng/UK
Distribution: /Debian3.1/suse/Win7/8/10
Posts: 680

Rep: Reputation: 30
hello to remove the file
"rm -rf filename"
 
Old 10-31-2004, 04:04 PM   #3
elfoozo
Member
 
Registered: Feb 2004
Location: Washington, USA
Distribution: Debian
Posts: 265

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by master
hello to remove the file
"rm -rf filename"
hi!,

No, that does not work. The file remains.
 
Old 10-31-2004, 04:51 PM   #4
master
Member
 
Registered: Oct 2003
Location: Birmingham/Eng/UK
Distribution: /Debian3.1/suse/Win7/8/10
Posts: 680

Rep: Reputation: 30
r u in the same directory as the file when u type the command
 
Old 10-31-2004, 05:09 PM   #5
elfoozo
Member
 
Registered: Feb 2004
Location: Washington, USA
Distribution: Debian
Posts: 265

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by master
r u in the same directory as the file when u type the command
I've tried it both ways: being in the same directory and not being in the same directory and typing the full path to file_name
 
Old 10-31-2004, 05:41 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
First use auto completion when trying to delete the file. Sometimes a file has some tricky characters that can fool you. Also, do you have write access permission on the files directory. Deleting a file is actually writing to the directory file, so you need write access on the directory itself.
Second, if the file is on an ext2 filesystem, it may have extended attributes. Use lsattr to find out if the 'immutable' attributes is set. The XFS file system has name:value pair extended attributes. Also, if you are using an SLE kernel. All files and processes have attribute pairs which control access.

If the sticky bit is set in on the containing directory, then only the owners can delete files.

One other thing with Linux and Unix that surprised me when I found out about it, is if the permission bits deny access to the owner, then the owner is denied access even if the owner has group permission. The same is true if the group permissions deny access to a group member, even if the other permissions would allow it.
This isn't the problem in your case because the permission bits allow it.

If another process or user has a lock on the file, you won't be able to delete it.
You can check this out with lsof <filename> | grep "<filename>" | grep -v grep

One other thing to check is if the file has a link referencing it. Look in the second column of the ls -l listing. If the second column is greater than 1 then that is the case.
Lastly, try deleting it using a file browser. The browser may reference the file by inode entry rather than by name.

Last edited by jschiwal; 10-31-2004 at 05:49 PM.
 
Old 10-31-2004, 06:33 PM   #7
elfoozo
Member
 
Registered: Feb 2004
Location: Washington, USA
Distribution: Debian
Posts: 265

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by jschiwal
First use auto completion when trying to delete the file. Sometimes a file has some tricky characters that can fool you.
doh!! Completely forgot about that.... that did the trick... the tab completion showed the file had hidden spaces at the end of file_name which were preventing me from manipulating it properly.

Thank you!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
delete file karunesh Linux - General 3 11-15-2005 01:49 AM
How do you delete a file?? The Pentium Guy Debian 7 11-01-2004 09:30 AM
How to delete a file Meatball1337 Linux - Software 1 10-04-2004 09:05 PM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
Delete contents of the file, but not file? mikeshn Linux - General 9 05-28-2003 06:47 AM

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

All times are GMT -5. The time now is 06:04 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