Computing.Net > Forums > Unix > prevent a file from being removed..

prevent a file from being removed..

Reply to Message Icon

Original Message
Name: shiok
Date: April 21, 2003 at 10:23:21 Pacific
Subject: prevent a file from being removed..
OS: unix
CPU/Ram: AMD
Comment:

What command can one use to prevent a file from being removed????


Report Offensive Message For Removal

Response Number 1
Name: rafamd
Date: April 21, 2003 at 21:18:02 Pacific
Subject: prevent a file from being removed..
Reply: (edit)

You can set the permissions of a file with the command "chmod". It's sintax usually is:
chmod NNN file, where NNN are numbers from 0 to 7:
0 - No permissions;
1 - can exec.;
2 - can write;
3 - can can write and exec.;
4 - can read;
5 - can read and exec.;
6 - can read and write;
7 - can read, write and exec.

The first N is the permissions for the owner, the 2nd for the group and the 3th for the others. So if you want to prevent the group and others to write into the file, but want that they read and exec it, and the owner can do everything with it, you must set it to 755.



Report Offensive Follow Up For Removal

Response Number 2
Name: WilliamRobertson
Date: April 22, 2003 at 16:25:38 Pacific
Subject: prevent a file from being removed..
Reply: (edit)

Or if you prefer, the alternative 'symbolic' syntax is along lines of:

chmod ugo-wr filename
chmod g+r, o-r filename

where

u = user
g = group
o = others

+ = add permission
- = remove permission
= = set to permission

r = read
w = write
x = execute (search for directories)

(Other options available - see 'man chmod')

I personally find this easier to remember than 755 etc.


Report Offensive Follow Up For Removal

Response Number 3
Name: shiok
Date: April 22, 2003 at 22:59:59 Pacific
Subject: prevent a file from being removed..
Reply: (edit)

but what if i want to ..say "lock" a file...and even prevent me from deleteing it or removing it...strictly read-only/..

is there any possible way?
thanks~



Report Offensive Follow Up For Removal

Response Number 4
Name: Don Arnett
Date: April 23, 2003 at 13:18:43 Pacific
Subject: prevent a file from being removed..
Reply: (edit)

The only way to guarantee that you can't delete a file is to remove all write permissions and NOT be the owner of the file.

An owner of a file can delete the file even if write permissions are off, although the system will prompt "Do you really want to do this?".

So, if you can change the owner of the file to 'root' (or some other user that you won't be) and remove all write permissions (chmod a-w filename), that's the best that you can do.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: prevent a file from being removed..

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software