LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 04-30-2002, 06:48 AM   #1
Eisenbart
LQ Newbie
 
Registered: Apr 2002
Distribution: SuSE
Posts: 7

Rep: Reputation: 0
Question Preventing single file from deletion


Hello everybody!

I have just started to deal with Linux and I am presently making myself familiar with the file access rights ( the chmod thing ). I am not quite sure wether I understood things correctly, but Im a bit dissappointed as certain things do not seem to be supported.

I find it strange that denying write permission for a file does not prevent it from being deleted; but I found out that you can deny write permission for the directory containing the file.

But this creates another problem, as it allows you to allow or deny deletion for ALL the files in a directory at once. And that brings us to the point:

I want to allow the deletion of any file in a folder except for one single file - how can I accomplish this?
 
Old 04-30-2002, 07:05 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
the owner of a file can always delete it, but OTHER users can't. as root, do chmod -w on a file and any other user can't delete it. you could always use chattr +i to set the file as immutable tho, which will prevent any changes at all while it is defined as such
 
Old 04-30-2002, 08:37 AM   #3
abrakadabra
Member
 
Registered: Apr 2002
Location: Denver
Distribution: SuSe,RedHat,Mandrake,
Posts: 109

Rep: Reputation: 16
Cool

Hi,
You can also use chmod with the t option to set the sticky byte on the file you don't want users to delete.

 
Old 04-30-2002, 09:13 AM   #4
Eisenbart
LQ Newbie
 
Registered: Apr 2002
Distribution: SuSE
Posts: 7

Original Poster
Rep: Reputation: 0
Talking of the sticky bit: My distribution ( SuSE ) came with a lousy manual, and although there were several hundred pages about all kinds of stuff, I found no explanation of the sticky bit - could someone please explain the stciky bit to me?
 
Old 04-30-2002, 09:50 AM   #5
Eisenbart
LQ Newbie
 
Registered: Apr 2002
Distribution: SuSE
Posts: 7

Original Poster
Rep: Reputation: 0
@acid_kewpie: I have just tried out what you said:

- The owner of a file can NOT always delete it, only if he has write permission for the directory containing the file

- Using chmod -w on a file does NOT prevent other users from deleting it, it only keeps them from changing its content.

Linux apparently does not regard the deletion of a file as a writing access!

It seems to me that a file can only be prevented from being deleted by disabling the write permission for the directory containing the file - and if this is true, there is a major design error in Linux access rights.
 
Old 05-01-2002, 06:24 AM   #6
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
They created the sticky bit on files to overcome exactly the sort of problems you are describing. Here is a nice explanation of the sticky bit:

http://linux.oreillynet.com/pub/a/linux/lpt/22_06.html
 
  


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
Preventing Linux from booting in Single User Mode LinuxSeeker Linux - Security 8 08-28-2009 07:12 AM
File Deletion mhkhalqani Linux - General 1 10-12-2005 03:08 AM
File Deletion Script disinformation Linux - Software 3 04-18-2005 07:00 AM
Problem with file-deletion after a while JohnWayne Linux - General 3 07-26-2004 12:57 PM
Perl and file deletion berry Programming 4 05-29-2002 06:42 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration