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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-08-2009, 10:42 AM
|
#1
|
LQ Newbie
Registered: Nov 2004
Posts: 2
Rep:
|
Need solution to prevent deletion of files but allow editing and writing.
I am trying to figure out a solution to a problem I have been posed. I need to make it so that a file can be opened, edited, and saved, but not deleted. The chattr -u won't cut it because that still allows the delete. Also, chattr -i won't work either because that won't allow for opening, writing, and saving. Thank you in advance for your help.
|
|
|
12-08-2009, 10:47 AM
|
#2
|
Member
Registered: Nov 2009
Location: Alabama
Distribution: EndeavourOS
Posts: 650
Rep:
|
You can use the stickybit. chmod +t
I think it can only be used on directories..... someone correct me if I'm wrong
Last edited by bret381; 12-08-2009 at 10:48 AM.
|
|
|
12-08-2009, 05:11 PM
|
#3
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430
|
Yeah, -t is only for dirs and only stops non-owners from deleting. You can't stop the owner for obvious reasons.
Another way is this:
1. Create a new master user eg m1 and a grp grp1 (this will be m1's primary grp)
2. create a dir /home/gshare owned by m1:grp1
3. chgrp +s /home/gshare
4. add reqd users to grp grp1 as secondary group
5. have all files created by m1
6. set dir perms rwxr-x---
7. set file perms rwxrw----
|
|
|
12-08-2009, 05:18 PM
|
#4
|
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,127
Rep: 
|
You could always make a directory that shadows the original one and has a hard link to each of the files, so even if they get removed out of the original the file still exists
|
|
|
12-09-2009, 02:50 PM
|
#5
|
ELF Statifier author
Registered: Oct 2007
Posts: 676
Rep: 
|
Quote:
Originally Posted by dsirrine
I am trying to figure out a solution to a problem I have been posed. I need to make it so that a file can be opened, edited, and saved, but not deleted. The chattr -u won't cut it because that still allows the delete. Also, chattr -i won't work either because that won't allow for opening, writing, and saving. Thank you in advance for your help.
|
Just wondering - if one allowed to edit file (include remove all of it content) while one shouldn't be allowed to delete this file ?
|
|
|
12-09-2009, 05:20 PM
|
#6
|
Moderator
Registered: Mar 2008
Posts: 22,359
|
You'd have to copy the file to a directory that the user can read and write to. Then on exit of app the script would do some compare to decide to edit original or leave. The original would have to be done with masked credentials. Might end up being hackable.
Wonder if NTFS formated partition would work?
|
|
|
12-10-2009, 01:38 AM
|
#7
|
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Rep:
|
Possibly not quite what you're after but might be part of a solution: the semi-legendary noclobber option. E.g.
SHELLOPTS=braceexpand:emacs:hashall:histexpand:interactive-comments:monitor:noclobber
|
|
|
12-10-2009, 02:02 AM
|
#8
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Remove write permission on the directory the files are in. The files' content can be deleted (that counts as editing, right?) but the files cannot be removed.
|
|
|
12-10-2009, 02:46 AM
|
#9
|
ELF Statifier author
Registered: Oct 2007
Posts: 676
Rep: 
|
Quote:
Originally Posted by catkin
Remove write permission on the directory the files are in. The files' content can be deleted (that counts as editing, right?) but the files cannot be removed.
|
Cool, I thought that removing write permission from directory will prevent file editing too, but I was wrong, it works.
Any idea WHY OP want such setup ?
|
|
|
12-10-2009, 02:15 PM
|
#10
|
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Rep:
|
Poisons rising from the gonads. 
|
|
|
12-10-2009, 02:46 PM
|
#11
|
ELF Statifier author
Registered: Oct 2007
Posts: 676
Rep: 
|
Quote:
Originally Posted by lugoteehalt
Poisons rising from the gonads. 
|
Can you explain - I didn't catch it 
|
|
|
12-10-2009, 02:55 PM
|
#12
|
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Rep:
|
Quote:
Originally Posted by Valery Reznic
Can you explain - I didn't catch it 
|
I intended it as witty remark, calculated to spread happiness. Clearly I miscalculated.
|
|
|
12-10-2009, 03:06 PM
|
#13
|
ELF Statifier author
Registered: Oct 2007
Posts: 676
Rep: 
|
Quote:
Originally Posted by lugoteehalt
I intended it as witty remark, calculated to spread happiness. Clearly I miscalculated.
|
May by you not miscalculated - just English is not my native language.
|
|
|
All times are GMT -5. The time now is 10:02 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|