Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

Or if you prefer, the alternative 'symbolic' syntax is along lines of:
chmod ugo-wr filename
chmod g+r, o-r filenamewhere
u = user
g = group
o = others+ = add permission
- = remove permission
= = set to permissionr = read
w = write
x = execute (search for directories)(Other options available - see 'man chmod')
I personally find this easier to remember than 755 etc.

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~

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.

![]() |
SED - Del Last Char of ev...
|
Unix SHELL SCRIPTS
|

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