LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-04-2008, 04:27 AM   #1
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Rep: Reputation: 0
Simple Question


Can a normal user delete files and folders created by root?
 
Old 07-04-2008, 04:53 AM   #2
uppman
Member
 
Registered: Jul 2008
Location: Stockholm, Sweden
Distribution: Slackware 13.1 32-bit
Posts: 145

Rep: Reputation: 24
Yes.
It can be done with the sudo command.

More info:
http://linuxconfig.dyndns.org:1184/l...28Slackware%29
 
Old 07-04-2008, 05:04 AM   #3
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 0
Well i created a folder in a user account as root and a file inside it... well the concept being the user not able to delete the file root created(it has default permission)... well the user cant delete the that folder that ok bind with the concept.. And my question is there is folder which is empty created by root but users(non root ones) can delete the folder and any files in there home directory created by root... well that's really annoying can any one tell the concept behind this... . Thanks in advance

#cd /home/user1

#touch 1

#mkdir test1

login user1


$ rm -rf test1 (it gets deleted) user and group is root for test1

$ rm -rf 1 (same with this file also
\

The normal users umask is 022
 
Old 07-04-2008, 05:12 AM   #4
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 0
Well i created a folder in a user account as root and a file inside it... well the concept being the user not able to delete the file root created(it has default permission)... well the user cant delete the that folder that ok bind with the concept.. And my question is there is folder which is empty created by root but users(non root ones) can delete the folder and any files in there home directory created by root... well that's really annoying can any one tell the concept behind this... . Thanks in advance

#cd /home/user1

#touch 1

#mkdir test1

login user1


$ rm -rf test1 (it gets deleted) user and group is root for test1

$ rm -rf 1 (same with this file also
\

The normal users umask is 022
 
Old 07-04-2008, 05:15 AM   #5
emi_ramo
Member
 
Registered: Apr 2007
Location: Barcelona, Spain
Distribution: Debian, KUbuntu
Posts: 213

Rep: Reputation: 36
It depends on which perms root let to these files. You can look at them with
Code:
ls -l
on the dir where files were created. It will give you something as (this is my /home)
Code:
total 7
drwxr-xr-x 40 user1   user1  2808 2008-07-02 15:54 user1
drwxr-xr-x  5 user2   user2   296 2007-11-27 18:50 user2
drwxrwsr-x  3 root    staff    72 2005-08-18 17:37 cvs
drwxr-xr-x  2 user3   user3   136 2006-09-18 12:09 user3
The first column is drwxr-xr-x. It means
d: it's a directory
rwx: it's readable, writable and executable by owner
r-x: it's readable and executable by users from the same group
r-x: it's readable and executable by others, not in the group

You can change this with chmod [type][+/-][perm]:
chmod o+w file => adds write perm to others
chmod g-r file => removes read permission to other users from the group
chown user:group file => changes user and group owner of the file
chown user file => changes user owner of the file
chgrp group file => changes group owner of the file

/etc/groups tells who is member of each group.

Have fun!!

emi
 
Old 07-04-2008, 05:30 AM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
When you remove a file, you are removing an entry from the directory. It is the directory permissions that control whether or not you can delete a file, not the file permissions. So, even though root owns the file, if you own the directory, you may remove the file from your directory. You can think of a directory as just a file itself, that contains a list of file names matched with what are called inodes. Deleting a file is removing the file name from the directory, and decrementing the reference count of the inode. Since there may be other links to that file somewhere else in the file system, the "unlinking" (what you call "delete") only decreases the number of references to that file. (when it goes to 0, there kernel also frees the data).

So, anyone who has permission to WRITE to the directory can modify the directory contents.

Upman: the question was whether or not an unprivileged user can remove another user's files. Sudo actually changes the user and group ids temporarily for the program that is run by sudo. So, sudo wouldn't count in this case as an answer to the question.

Last edited by Mr. C.; 07-04-2008 at 05:32 AM.
 
Old 07-04-2008, 08:18 AM   #7
uppman
Member
 
Registered: Jul 2008
Location: Stockholm, Sweden
Distribution: Slackware 13.1 32-bit
Posts: 145

Rep: Reputation: 24
Ok, if I now understand correctly: You don't want an ordinary user to be able to delete a file owned by root?

I think that could be acomplished by using AppArmor, SELinux or Linux-PAM..
 
Old 07-04-2008, 01:53 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
... or the directory owner can be changed, or set more restrictive controls via chattr -i.
 
Old 07-04-2008, 09:48 PM   #9
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 0
Thank.. I got it?
 
  


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
Two things: (Probably Simple) Grub question, and a gDesklets question Wilffo Linux - Software 3 05-20-2006 02:33 PM
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 03:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 10:03 PM
simple yes or no question! Suspect Linux - Newbie 8 07-25-2002 12:40 AM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 05:08 AM


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