LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   File Permissions (https://www.linuxquestions.org/questions/linux-newbie-8/file-permissions-745763/)

lothario 08-07-2009 03:47 AM

File Permissions
 
I have file in my home directory.
I want other users on this system to be able to read from this file and write to this file.
But I don't want anyone to be able to delete this file.
How can I do this?

ap0calypse 08-07-2009 04:12 AM

I guess what you want is not really possible. If you give write permission to a file, the person also has the right to delete it.

PMP 08-07-2009 04:32 AM

well This is possible, This happens the case with /tmp directory.
The non-owner user will not be able to delete it even if it has got 777 permission.

check the permission on /tmp directory. If am not sure wether you will be able to achieve what you exactly want but this is possible

Thats basically is sticy bit on /tmp i.e the last t in the permissions.

Explore over it.

b0uncer 08-07-2009 04:45 AM

It is possible, with the use of sticky bit. If you set it on a directory, then files inside that directory can only be renamed or removed by the owner of that directory, even if other users have write permissions to the files there.

Code:

chmod +t /home/username/dirname
That should do it. If you'll look at the permissions of a directory where sticky bit is set, you'll notice there are "t" letters where the usual "x" (execute) letters usually are. See

Code:

ls -ld /tmp
for an example

jschiwal 08-07-2009 04:54 AM

Allowing other users to access your home directory isn't a good idea. Put a copy of the file in /tmp/ or a publicly accessible directory which has the sticky bit set. In order to access this file, they would need rx permissions on the parent directory.

and235100 08-07-2009 05:08 AM

If this file is on an ext2 or ext3 filesystem, then you could use chattr +u.

This would make the file undeletable.


All times are GMT -5. The time now is 02:31 AM.