LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Make a file not overwriteable (https://www.linuxquestions.org/questions/linux-newbie-8/make-a-file-not-overwriteable-4175423493/)

ted_chou12 08-22-2012 04:27 PM

Make a file not overwriteable
 
Hi, I don't know why, whenever I "touched" my admin network options, it tries to overwrite my /etc/resolve.conf file, and this causes me not able to connect to the www properly. I have to take some time to figure out this problem when it occurs and I have to login as root to edit the file. I wish to make the file not overwriteable. I already chmod the file to 444 only, but it seems still to be able to be overwrited, the system seems to have the power of root. I wonder if I could "fix" the file somehow so that the system can't modify it.
Thanks,
Ted

Habitual 08-22-2012 04:33 PM

sudo chmod 0000 /path/to/file ?

TobiSGD 08-22-2012 04:37 PM

Code:

chattr +i /etc/resolv.conf
will set the immutable flag for the file in question. For more info on chattr have a look at
Code:

man chattr

sag47 08-22-2012 04:39 PM

Set the file to be immutable.

Code:

chattr +i /etc/resolv.conf
To disable it just
Code:

chattr -i /etc/resolv.conf
edit: ah tobi beat me to it :)

ted_chou12 08-22-2012 04:52 PM

Thanks!

SharpyWarpy 08-22-2012 08:02 PM

I use
Code:

chattr +i cover_image.jpg
on front cover images of albums. Since I keep the front cover images in the same directory as the mp3 files making the image immutable helps me avoid mistakes like
Code:

id3v2 -a Foreigner *
in which case the poor image would have undesirable id3 tag information were it not immutable. That's just one example. And my 2 cents worth. :)


All times are GMT -5. The time now is 05:06 PM.