LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 01-16-2013, 10:55 PM   #1
Anup D.
LQ Newbie
 
Registered: Jan 2012
Location: Nanded
Distribution: RHEL
Posts: 25

Rep: Reputation: Disabled
Can't delete directory and files


Hello Friends,

My one of the OpenVZ container backup failed and it had created it's tmp directory:
# ls -l /backups/vps/2013-Jan-14
drwxr-xr-x 4 root root 4096 Jan 15 03:26 vzdump-openvz-101-2013_01_14-22_50_09.tmp

This above directory contains some below files :
# ls -ila
total 8250080393
24609288 drwxr-xr-x 1 10009 2524 4096 Jan 17 03:23 .
24609283 drwxr-xr-x 3 10009 2524 4096 Jan 17 03:23 ..
25165834 br-srwSr-T 8274 824200736 976835141 32, 57 Nov 12 2022 btn_bg-disabled.gif
25165836 br-sr---wt 14128 1280210021 1998600761 78, 95 Apr 2 1987 btn_cgi_bg.gif
25165837 br-xr-srwT 8265 1415275040 1969771331 91, 32 Aug 15 2011 btn_coldfusion_bg.gif
25165839 dr-s--xrwT 19744 540035423 808613224 1230193491 Mar 9 1987 btn_miva_bg.gif
25165840 dr-x--x--t 21573 1801670239 1952796192 1635197004 Sep 13 2028 btn_ok_bg.gif
25165841 c---r----- 12849 1735285536 1646276658 110, 105 Nov 15 1999 btn_perl_bg.gif
25165843 ?--Srwx--T 28265 1263416624 1230987808 825242144 Jan 10 2026 btn_python_bg.gif
25165844 ?r--r----T 14641 1128883055 1314857017 175400299 Jan 2 2011 btn_refresh-list_bg.gif
25165845 ?--xr-s--x 17235 538996329 1528842591 1768038503 Oct 20 2014 btn_ssi_bg.gif
25165846 br-x--xr-x 8268 1735270514 1948274271 110, 105 Sep 7 1996 dBox-footer-bg.gif
25165847 d--s-wSr-- 26708 976768585 858872608 1397317451 Sep 15 2006 dBox-header-left.gif
25165848 ?r-SrwS-w- 8303 1931495758 1668248608 1280204611 Sep 13 2028 dBox-header-right.gif

I want to delete above all files but is not allowing to do so.
Whenever I try to delete those it gives below error:
# rm -rf btn_bg-disabled.gif
rm: cannot remove `btn_bg-disabled.gif': Operation not permitted

I tried to delete using inode values but the error is same.
# find . -inum 25165841 -exec rm -i {} \;
rm: remove write-protected character special file `./btn_perl_bg.gif'? y
rm: cannot remove `./btn_perl_bg.gif': Operation not permitted

Please help me to delete this files.

Thanks
Anup
 
Old 01-17-2013, 04:43 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It looks like you may have a corrupted filesystem.

I don't think having device files show up like that can be anything else.

Now it is possible to get that error on systems running SELinux - it usually is caused by going to root with "su" instead of "su -" before trying to delete files with security labels than prevent deletion.
 
Old 01-26-2013, 04:03 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Many of these files have SUID or SGID set, plus some of them do not have write permission also.

So if your motive is just to remove these files, then you can try to change their permission mode first and then remove SUID/SGID. And then try to remove files as:-
Code:
~$ cd /backups/vps/2013-Jan-14
~$ chmod 777 ./*
~$ chmod u-s,g-s,a-t ./*
~$ rm -rf <filename>
To me, these files look corrupt (you can see garbled link count, owner and group attributes).

Last edited by shivaa; 01-26-2013 at 04:05 AM.
 
Old 01-26-2013, 09:19 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Just as a note - it isn't necessarily the files that are corrupt.

It is the inode that is corrupt. And that points to a disk error or other much worse filesystem corruption.

Deleting the files could just make things worse as freeing up these inodes would make them available for reuse- which could also get corrupted. There is also the problem of the blocks released - if the problem carries on into the filesystem data, (such as duplicate allocations) doing this could cause the other files (which are not yet corrupt) to become corrupted.

you really need to dismount this filesystem and run fsck to see what it reports as bad.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Would like to delete all files in a directory except the 7 latest ones vbekker Linux - Newbie 19 12-13-2010 01:25 PM
Delete files in a directory - RM MDeFreitas Linux - Newbie 3 06-25-2010 07:00 AM
Delete Files in directory villumanati Linux - General 7 12-30-2008 01:18 PM
rm can't delete 999999 files in one directory yelo Linux - Software 10 04-10-2004 02:00 PM
How can I delete a directory and its files? OrganicX Linux - General 6 09-01-2002 04:25 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 07:06 PM.

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