Need solution to prevent deletion of files but allow editing and writing.
Linux - NewbieThis 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.
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.
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.
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----
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
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 ?
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.