1836768 Members
2296 Online
110109 Solutions
New Discussion

Permisions for others

 
Marcelo De Florio_1
Frequent Advisor

Permisions for others

How can i grant permisions of write to others (in directory) but not read and remove files ?

MDF
Marcelo De Florio
7 REPLIES 7
Sridhar Bhaskarla
Honored Contributor

Re: Permisions for others

Hi,

You can use the command

chmod 702 file.

Make the owner of the parent directory to root.

This will not make them to read or delete the file. But the problem is, whatever they write into the file using vi will overwrite the contents. They can use >> command to write into it.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
S.K. Chan
Honored Contributor

Re: Permisions for others

>>How can i grant permisions of write to others (in directory) but not read and remove files ?

Say the dir is /opt/apps/dirA owned by root:lab .

# cd /opt/apps
# chmod 752 dirA
==> which gives rwxr-x-w-

Sachin Patel
Honored Contributor

Re: Permisions for others

rwxrwxrwx
1st three from left are owner of file.
middle three are for group permission for that file.
last three are others permission.

rwx = 4 2 1 = 7 if you want to set that
r-x = 4 1 = 5 if setup is read write

So if setup is
rwxr-x-w- then 752 = rwx for owner, rx for group and write for others.

Sachin
Is photography a hobby or another way to spend $
Marcelo De Florio_1
Frequent Advisor

Re: Permisions for others

ok, but if i need, the others write file need execute permisions, so the permisios eg: 753, so the users not read of directory but remove files.

How can i resolve this problem?

MDF
Marcelo De Florio
Jeff Schussele
Honored Contributor

Re: Permisions for others

Note that if you don't grant read perms on a file it cannot be "editted" as the editor has to read it into memory. If only write is granted they can only write into the file directly. AND the caveat is the user CAN delete the file as that is a write function.
Moral => there is NO way to grant write perms w/o delete perms.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
James R. Ferguson
Acclaimed Contributor

Re: Permisions for others

Hi Marcelo:

I think what you really want is to set the directory's sticky bit. This will prevent the removal (deletion) of a file by a user other than the owner, or of course, 'root'. In this way, any user can write (create) files in the directory and listings of the contents of the directory can still be obtained. The permissions of the files themselves will allow or deny reading them. Have a look at the man pages for 'chmod'. Do this:

# chmod 1777 mydir

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Permisions for others

Not granting read permission means that the files cannot be executed. The reason is that when a shell script is run, the shell must open the file and read the contents, so a file with -wx permissions will not run. And as mentioned, writing to the file can only occur with general commands like appending to the end. Editors like vi will require read capability on the file.


Bill Hassell, sysadmin