LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 05-12-2008, 04:23 AM   #1
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Rep: Reputation: 0
Talking Cannot remove files


Problem:
When i login as normal user in server,i cannot delete any file. Even i already chmod 777 to specific file.
Why user cannot remove file? Root(administrator) can do anything.
example:
login as root
chmod 777 testing.txt (root exec)
exit

login as user: user
rm testing.txt (fail because permission denied)


Situation try to solve(fail too)

i try add user as same group with root. example : root group is under root.
User join into root group.
Try delete/remove the file under chown into root group. Because same group is allow delete/remove file.

chgrp root testing.txt

login as user: user
rm testing.txt (fail because permission denied)


Really hope anyone to help solve this problem.THANKS FOR HELP
 
Old 05-12-2008, 04:40 AM   #2
elthox
Member
 
Registered: Oct 2006
Posts: 41

Rep: Reputation: 15
Quote:
Originally Posted by poin04 View Post
Problem:
When i login as normal user in server,i cannot delete any file. Even i already chmod 777 to specific file.
Why user cannot remove file? Root(administrator) can do anything.
example:
login as root
chmod 777 testing.txt (root exec)
exit

login as user: user
rm testing.txt (fail because permission denied)


Situation try to solve(fail too)

i try add user as same group with root. example : root group is under root.
User join into root group.
Try delete/remove the file under chown into root group. Because same group is allow delete/remove file.

chgrp root testing.txt

login as user: user
rm testing.txt (fail because permission denied)


Really hope anyone to help solve this problem.THANKS FOR HELP
Can you list here the permission field of the file

ls -l
 
Old 05-12-2008, 04:48 AM   #3
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
Yes root can do any thing even destroying the system
A user get privilege to do certain things no more
About files who is the owner of the file
As example in Suse I have 3 users they have the privilege to delete their own files in their own home/dir
Root can delete them all

all the best
 
Old 05-12-2008, 05:12 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by poin04 View Post
chmod 777 testing.txt (root exec)
I'm assuming this means the file is owned by root and group exec. If that is the case, then, as far as I'm aware, the user trying to delete the file either needs to be root, or in the group exec.
 
Old 05-12-2008, 06:05 AM   #5
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 549

Rep: Reputation: 38
try rm -f file
 
Old 05-13-2008, 03:55 AM   #6
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
rm -f file ( this is not work even user try force to delete) ---> permission denied

i put chmod 777 testing.txt (root exec) ===> this mean everyone is able to read,exec,write


Problem:
user cannot delete file(which create by root) even is same group

i already put
chmod g+rw testing.txt
chown :root testing.txt ( i using root as group exec)

user try to delete testing.txt
rm -f testing.tx (permission denied)

Last edited by poin04; 05-13-2008 at 04:01 AM.
 
Old 05-13-2008, 04:09 AM   #7
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
what happens if you try

touch test.file

rm test.file

If you can't touch the file, I'd suggest the issue is the permissions of the directory the file is in, not the file. You need write access to the directory.
 
Old 05-13-2008, 04:36 AM   #8
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
i also try using touch before

root login:root
touch testing.txt

change to user login:user

rm testing.tx (permission denied)


List the file:
ls -ln

(777 permi) (user) (group-root)
-rwxrwxrwx 1 10000 0 28721 2008-05-13 17:35 testing.txt


user@localhost$ id
uid=10000(user) gid=0(root) groups=0(root)

Last edited by poin04; 05-13-2008 at 04:40 AM.
 
Old 05-14-2008, 03:33 AM   #9
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
please help!!! anyone got good solution for this.. I already test many time..The result is still same.
Hope can solve this problem..THanks
 
Old 05-14-2008, 03:52 AM   #10
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Did you read my post? You need to check the directory permissions
 
Old 05-14-2008, 04:07 AM   #11
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656
Could you indicate the full pathname for the file? Also list the permissions of the directory. (ls -ld <dirname>)

A users needs write access to the directory to delete a file. Also, if the directory has the sticky permission bit set, then only an owner of a file inside that directory can delete it. If root creates a file in a users home directory, that user, being the owner of the directory is able to delete the file.
Here is an example where I created a directory. Notice the permissions on the directory. I removed write access for myself after creating the directory and copying the files there. Even though I am a member of the group owner of the directory, I can't delete the file. ( This may be different than other *nixes. )
Code:
ls -l sampledir/
total 4
-r-----rw- 1 jschiwal jschiwal 0 2008-05-14 03:55 sample
-r-------- 1 jschiwal jschiwal 0 2008-05-14 03:55 sample2
> ls -ld sampledir
dr-xrwxrwx 2 jschiwal jschiwal 4096 2008-05-14 03:56 sampledir
> rm sampledir/sample
rm: remove write-protected regular empty file `sampledir/sample'? y
rm: cannot remove `sampledir/sample': Permission denied
Creating files or deleting files is an operation on the directory, so it is the permissions that are important.

A file could also have extended attributes set. If the "i" bit is set, then even root can't delete the file until the "i" attribute is cleared. The filesystem needs to support these attributes.
Code:
chmod ug=rw sampledir/sample
> chattr +i sampledir/sample
chattr: Operation not permitted while setting flags on sampledir/sample
> sudo chattr +i sampledir/sample
root's password:
> ls sampledir/* -l
-rw-rw-rw- 1 jschiwal jschiwal 0 2008-05-14 03:55 sampledir/sample
-r-------- 1 jschiwal jschiwal 0 2008-05-14 03:55 sampledir/sample2
> lsattr sampledir/
-------------- sampledir/sample2
----i--------- sampledir/sample
> rm sampledir/sample
rm: remove write-protected regular empty file `sampledir/sample'? y
rm: cannot remove `sampledir/sample': Operation not permitted
> sudo rm sampledir/sample
rm: remove write-protected regular empty file `sampledir/sample'? y
rm: cannot remove `sampledir/sample': Operation not permitted

Please remove that user with root permissions. That is a bad idea.
 
Old 05-14-2008, 04:30 AM   #12
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
hmm.. i understand.
I think this not related to the stick set problem. I didn't set it with chatr command.
chatr +i "testing.txt" ===> to make hidden file (this make root is unable to remove it)

billymayday, sorry about make you misunderstanding. Problem: permission is not the issue.
Even you put rewrite,exec,read to that file. User is able to rewrite,exec,read but user is unable to delete specific file.

Problem:
if any file under subfolder(root), That mean user are no permission to delete it.
if any file under /home/user(user own folder) , that mean user are able to delete it??
 
Old 05-14-2008, 11:57 PM   #13
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656Reputation: 656
That isn't a problem. You shouldn't have files in /root/. I already explained that it is the write permissions on the directory that are needed to create or delete files inside the directory. A regular user shouldn't even be able to enter the /root/ directory. The sticky bit isn't set with chattr. It is set using chmod. The /tmp directory has this bit set. So a non-owner of a file will not be able to delete a file in /tmp even though they have write permission on the directory.
 
Old 05-15-2008, 03:01 AM   #14
poin04
LQ Newbie
 
Registered: Jul 2006
Posts: 8

Original Poster
Rep: Reputation: 0
hmm..ok i understand what you mean..
Thanks a lot
 
Old 05-15-2008, 05:12 AM   #15
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Quote:
billymayday, sorry about make you misunderstanding. Problem: permission is not the issue.
Even you put rewrite,exec,read to that file. User is able to rewrite,exec,read but user is unable to delete specific file.
Permission was the issue, but permissions for the directory as I pointed out in my first post
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove files - the command Cheloo Linux - General 4 03-24-2008 01:24 AM
remove some files from a dir wkwireless Linux - Software 5 01-24-2007 07:49 AM
remove ~ from all files and folders BoraX Linux - General 1 10-25-2006 07:58 PM
remove a lot of files matko Linux - General 1 07-08-2004 03:33 AM
Script to remove old files. cmfarley19 Linux - General 2 03-24-2003 01:15 PM


All times are GMT -5. The time now is 12:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration