LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rm -rf, chmod as root: permission denied? (http://www.linuxquestions.org/questions/linux-newbie-8/rm-rf-chmod-as-root-permission-denied-832150/)

megaplux 09-14-2010 03:00 PM

rm -rf, chmod as root: permission denied?
 
I am logged in and su'ed to the root account,
I get a permission denied error when I try to rm -rf or chmod a file that is in the /home directory. it is a .bak file, and nothing seems to be using it. Any ideas? It is huge (18+ gig) and I want to delete it, it is backed up elsewhere

thanks

yancek 09-14-2010 06:13 PM

Quote:

It is huge (18+ gig) and I want to delete it, it is backed up elsewhere
Files with a ".bak" extension are generayll backup files so it's a little strange to have a backup file backed up elsewhere?? What does the ls -l command run against the file name show for permissions?

Tinkster 09-14-2010 07:48 PM

Quote:

Originally Posted by megaplux (Post 4097461)
I am logged in and su'ed to the root account,
I get a permission denied error when I try to rm -rf or chmod a file that is in the /home directory. it is a .bak file, and nothing seems to be using it. Any ideas? It is huge (18+ gig) and I want to delete it, it is backed up elsewhere

thanks

Hi, welcome to LQ!

Filesystem?
Mount options?
Extended attributes?


Cheers,
Tink

megaplux 09-15-2010 08:26 AM

the file is in /home

ls -l output:

-rw-r--r-- 1 root root 18727761920 Aug 12 2009 charley9.tar.gz.bak


mount output

/dev/sda6 on /home type ext3 (rw,usrquota)


root@host [/home]# getfacl --all-effective charley9.tar.gz.bak
# file: charley9.tar.gz.bak
# owner: root
# group: root
user::rw-
group::r--
other::r--

druuna 09-15-2010 08:44 AM

Hi,

I see that you use the usrquota option when mounting.

How do you become root? Do you use su or su - (or possibly sudo su)? You might want to try su -, that gives you a full blown root account with all environment settings etc (su does not).

I'm not able to check how the quota system reacts to root that does not have a full blown root account, it could be that the underlying user environment settings are used and a permission denied is given.

I did check if there is a difference between su and su - when quota's are not in effect: Both should be able to rm or chmod (at least on my box...).

Hope this helps.

MiKOTRON 09-15-2010 08:56 AM

See if you can chown it to another user then rm -r -f it.

megaplux 09-15-2010 01:09 PM

I have tried both su and su - and there does not seem to be a difference,

chown did not give an error,
but then chmod would not work


Quote:

root@host [/home]# chmod +x charley9.tar.gz.bak
chmod: changing permissions of `charley9.tar.gz.bak': Operation not permitted

root@host [/home]# rm -r -f charley9.tar.gz.bak
rm: cannot remove `charley9.tar.gz.bak': Operation not permitted


AARRGGHHH!!!

Tinkster 09-15-2010 01:39 PM

How about an lsattr on both the file & the directory it's in?

druuna 09-15-2010 01:44 PM

Hi,

What is the output of:

stat /home/charley9.tar.gz.bak

and

lsof /home/charley9.tar.gz.bak

megaplux 09-15-2010 03:36 PM

root@host [/]# lsattr home/charley9.tar.gz.bak
----i-------- home/charley9.tar.gz.bak



root@host [/]# stat /home/charley9.tar.gz.bak
File: `/home/charley9.tar.gz.bak'
Size: 18727761920 Blocks: 5332880 IO Block: 4096 regular file
Device: 806h/2054d Inode: 1063194 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-09-14 13:54:02.000000000 -0400
Modify: 2009-08-12 11:23:22.000000000 -0400
Change: 2009-08-12 11:25:49.000000000 -0400



root@host [/]# lsof /home/charley9.tar.gz.bak
root@host [/]#

druuna 09-15-2010 03:48 PM

Hi,

We (Tinkster to be exact!) found it.

The i flag that the lsattr output shows tells you that the file cannot be changed easily (its immutable, have a look at the chattr man page).

As root: chattr -i /home/charley9.tar.gz.bak. Now the file can be handled as you expect.

A little warning/caution: You do have to ask yourself, or someone else if the box isn't yours: Why was this attribute set? Is the file that important?

Hope this helps.

megaplux 09-15-2010 03:55 PM

FIXED

chattr -i charley9.tar.gz.bak

rm -rf charley9.tar.gz.bak

I fixed it before I read the above post. Thanks everyone, I will try and help to solve other questions!!!

And I do got a backup of it :)


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