PDA

View Full Version : [ubuntu] [SOLVED] Preventing deletion and modification?



daltonlaffs
June 18th, 2008, 04:18 PM
Hello Ubuntu peoples (and other assorted Linux distro peoples),

There's a file on my system that I need to prevent writing and deletion to/of, but still allow reading and executing in Terminal.

I've tried chown-ing the file to Root and chmod-ing the file to 755, but it can still be deleted, and even worse, can't be restored from the Trash.

Is there any way to do this?

Thanks in advance, guys :)

Dr Small
June 18th, 2008, 04:27 PM
chmod 775 file
chown root:root file

daltonlaffs
June 18th, 2008, 04:31 PM
Nope, it can still be deleted by anyone... any other ideas?

John.Michael.Kane
June 18th, 2008, 04:47 PM
Have you tried.


chmod 400 file
or

chmod 444 file

daltonlaffs
June 18th, 2008, 05:04 PM
Have you tried.


chmod 400 file
or

chmod 444 file

Nope, still deletable. I don't think we can pull this off in regular file access, there's got to be some other way...

cdenley
June 18th, 2008, 05:38 PM
The file can be deleted by anyone with write access to the parent directory.



cd /path/to/parent
sudo chown root:root .
sudo chmod 755 .

brian_p
June 18th, 2008, 05:45 PM
There's a file on my system that I need to prevent writing and deletion to/of, but still allow reading and executing in Terminal.

This file is in your home directory?

Which users do you want to be prevented from deleting the file?

Biochem
June 18th, 2008, 05:50 PM
chattr +i file

will prevent even root to accidentally delete or modify the file unless chattr -i is invoked first

works on ext2/3

daltonlaffs
June 18th, 2008, 06:26 PM
Yes!

Thanks to Cdenley and Biochem, I used both of your methods on the folder (not any individual file) and now the entire folder is read and delete-proof!

Thanks a billion, guys! :guitar:

Dr Small
June 18th, 2008, 06:42 PM
chattr +i file

will prevent even root to accidentally delete or modify the file unless chattr -i is invoked first

works on ext2/3
Then that's what I need to do to /boot, because last night I accidentially deleted it :D