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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

prevent a file from being removed..

Reply to Message Icon

Name: shiok
Date: April 21, 2003 at 10:23:21 Pacific
OS: unix
CPU/Ram: AMD
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: rafamd
Date: April 21, 2003 at 21:18:02 Pacific
Reply:

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.



0

Response Number 2
Name: WilliamRobertson
Date: April 22, 2003 at 16:25:38 Pacific
Reply:

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.


0

Response Number 3
Name: shiok
Date: April 22, 2003 at 22:59:59 Pacific
Reply:

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~



0

Response Number 4
Name: Don Arnett
Date: April 23, 2003 at 13:18:43 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


SED - Del Last Char of ev... Unix SHELL SCRIPTS



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: prevent a file from being removed..

copying a file from a diskette? www.computing.net/answers/unix/copying-a-file-from-a-diskette/1771.html

FTP a file from NT to UNIX box www.computing.net/answers/unix/ftp-a-file-from-nt-to-unix-box/4191.html

Moving file from Unix to NT www.computing.net/answers/unix/moving-file-from-unix-to-nt/1784.html