LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-14-2010, 03:00 PM   #1
megaplux
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 1
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
 
Old 09-14-2010, 06:13 PM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
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?
 
Old 09-14-2010, 07:48 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by megaplux View Post
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
 
Old 09-15-2010, 08:26 AM   #4
megaplux
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 1
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--
 
Old 09-15-2010, 08:44 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 09-15-2010, 08:56 AM   #6
MiKOTRON
LQ Newbie
 
Registered: Jul 2009
Distribution: SUSE, Mandrivia, Gentoo
Posts: 8

Rep: Reputation: 0
See if you can chown it to another user then rm -r -f it.
 
Old 09-15-2010, 01:09 PM   #7
megaplux
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 1
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!!!
 
Old 09-15-2010, 01:39 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
How about an lsattr on both the file & the directory it's in?
 
Old 09-15-2010, 01:44 PM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

What is the output of:

stat /home/charley9.tar.gz.bak

and

lsof /home/charley9.tar.gz.bak
 
Old 09-15-2010, 03:36 PM   #10
megaplux
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 1
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 [/]#

Last edited by megaplux; 09-15-2010 at 03:39 PM.
 
1 members found this post helpful.
Old 09-15-2010, 03:48 PM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
1 members found this post helpful.
Old 09-15-2010, 03:55 PM   #12
megaplux
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 1
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

Last edited by megaplux; 09-15-2010 at 03:59 PM.
 
  


Reply

Tags
chattr, filesystem, root



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
Permission denied even with chmod 777 Zabrajin Linux - Newbie 19 02-06-2011 07:40 AM
Chmod , permission denied theWolve Linux - Newbie 6 01-29-2010 10:06 PM
BIND 9 Permission denied when chmod is 777 o_O KasperLotus Linux - Networking 10 09-07-2005 12:20 AM
BIND 9 Permission denied when chmod is 777 o_O KasperLotus Linux - Software 0 08-28-2005 11:42 PM
chmod : permission denied onebyone Linux - Software 4 01-27-2004 02:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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