Results 1 to 8 of 8
Hi all..
I want to create a file which never delete from any of command, utility,any user and it should removed only when i format my disk..
Could you any ...
- 12-04-2007 #1Just Joined!
- Join Date
- Jan 2007
- Location
- India
- Posts
- 10
how to create never deleting file.
Hi all..
I want to create a file which never delete from any of command, utility,any user and it should removed only when i format my disk..
Could you any one tell me the solution or idea?
Thanks in advance.
Ganesh
- 12-04-2007 #2
I'm curious why you want to do this, but you can make a file untouchable by anyone other than root with chmod 700. I don't know if it's possible to make a file untouchable by root user though.
Registered Linux user #270181
TechieMoe's Tech Rants
- 12-04-2007 #3Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
I have seen occasionally where a logfile can be written to but not read - chmod 744 somefile. This means that users only have a one way interaction with a file.
- 12-04-2007 #4
As far as I know, this is rather impossible, except on the kernel level.
The reason for this is simple: first off, the root user has 777 permissions on everything in the system (except for files that the kernel prohibits this on). Secondly, even if you are not allowed to write to a file, if you have write permissions on a directory, you can delete files inside of that directory.
Maybe there is some sort of program / kernel module that allows you to specially protect files? See if you can find anything: I'd be interested.DISTRO=Arch
Registered Linux User #388732
- 12-04-2007 #5forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,095
I was thinking you could do it with chattr and the i attribute:
The file would still deletable by root but only after he removes the immutable flag.Code:chattr +i filename
oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.
- 12-04-2007 #6
chattr +i (immutable) is the way to do this.
But that alone isn't enough. You need to make it so that even root can not remove the immutable attribute. To do this, you need lcap.
Protecting the file would work like this:
- Make it immutable using chattr.
- Remove the immutable capability (and a couple others, explained in the manpage) altogether using lcap.
Now no one, not even root, can modify or delete that file. In order to delete it, a reboot would have to occur (in order to get the ability to change immutable attributes back). And you need to be monitoring for/preventing reboots anyway.
- 12-04-2007 #7
Interestingly, I've never used chattr before. Cool beans.
One thing I do note is that (according to the man page, at least), it only works with ext* filesystems. Is there a comparable program for ReiserFS, etc.?DISTRO=Arch
Registered Linux User #388732
- 12-05-2007 #8


Reply With Quote