Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-12-2014, 10:03 PM   #1
Registered: Oct 2012
Posts: 46

Rep: Reputation: Disabled
prevent deleting important files

HI Friends,

Is there anyway to prevent deleting important fills, this is for ROOT user
Ex= /home/Script/
there is so many scripts inside this directory, so i want to prevent accidentally deleting files inside this. Is there any way to do this, or give warning before deleting for ROOT user.
Old 06-12-2014, 10:41 PM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
You can always mark them "immutable" (see documentation on chattr).

Once marked they cannot be deleted or altered without first removing the immutable flag.
Old 06-12-2014, 11:04 PM   #3
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 813

Rep: Reputation: 264Reputation: 264Reputation: 264
A few things pop to mind, depending on what you need.

If you almost never need to change the script, you could burn to a CD or DVD. If you change them every now and then, you could probably get away with a rewritable disc.
You could also use an SD card. Most SD cards have a "lock" switch on the side. When activated (IIRC) it prohibits anything from writing to it, but it can still be read.
Also, you could have a separate partition on your hard drive, and mount it as read-only.

However, even if you did manage to erase the script, you could always restore from your backup, right???? But seriously, if the scripts are important, it would be very unwise to have only one copy of them.

Hope this helps!

Last edited by maples; 06-12-2014 at 11:13 PM.
Old 06-12-2014, 11:05 PM   #4
Registered: Oct 2012
Posts: 46

Original Poster
Rep: Reputation: Disabled
Thanks friends It is great,
Old 06-14-2014, 07:53 PM   #5
DJ Shaji
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 517
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
Originally Posted by lahirushanaka View Post
Thanks friends It is great,
An unmatched left parenthesis creates an unresolved tension that will stay with you all day

Apart from the immutable flag, you could also chown root and chmod 000 to make it invisible to pretty much everybody. Root could still delete it though.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can superuser prevent a KDE 4.6user from deleting icons from his desktop? lewster Linux - Desktop 7 03-30-2011 03:50 PM
Prevent user from deleting files on pureftpd Skillz Linux - Software 2 02-21-2010 01:29 AM
How to prevent apt from deleting packages in /var/cache/apt/archives ? abc.linux Debian 11 11-07-2009 12:46 PM
Prevent root from deleting files on network mounts bobwall Linux - Server 9 08-28-2008 08:31 PM
Changing File Permission in a FTP directory to prevent deleting of files shawnbishop Linux - Software 3 01-10-2006 06:41 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration