LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2009, 03:47 AM   #1
lothario
Member
 
Registered: Apr 2004
Posts: 340

Rep: Reputation: 30
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?
 
Old 08-07-2009, 04:12 AM   #2
ap0calypse
Member
 
Registered: Jul 2009
Location: Austria
Distribution: Slackware
Posts: 38

Rep: Reputation: 16
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.
 
Old 08-07-2009, 04:32 AM   #3
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
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.

Last edited by PMP; 08-07-2009 at 04:36 AM.
 
Old 08-07-2009, 04:45 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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

Last edited by b0uncer; 08-07-2009 at 04:50 AM.
 
Old 08-07-2009, 04:54 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.
 
Old 08-07-2009, 05:08 AM   #6
and235100
LQ Newbie
 
Registered: Feb 2007
Distribution: SuSE 11.1/11.0, Fedora, RHEL
Posts: 24

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

This would make the file undeletable.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File permissions v. directory permissions Completely Clueless Linux - Newbie 7 07-09-2009 08:33 AM
how to hide a file using file permissions in linux without using dot davender84 Linux - General 4 03-26-2009 12:13 AM
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM
Changing file permissions on a SAMBA file share apenney Linux - Software 0 02-11-2002 04:42 PM


All times are GMT -5. The time now is 04:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration