Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there a way to have a file in the user's FTP home directory without the ability to modify/remove it from that directory over FTP?

So the user has write permissions on his own home folder, thus the ability to remove files. An exception should be made for a single file, which has the same filename and contents for each account.

The solution I'm thinking of right now to run a periodic script to check the presence of that file, and if not, put it back. But I wonder whether there's a better solution than this.

share|improve this question

3 Answers 3

What filesystem do you have? You can try setting immutable attribute on that file

chattr +i filename
share|improve this answer

As stated, a file can be removed if you have write permission on the directory where it resides. However, you cannot remove a directory if it isn't empty, even if you have write permission on the parent directory. Thus, this hack should work:

mkdir protected
touch protected/test
sudo chown -R root:root protected
sudo chmod -R 755 protected

Now if you try to remove file:

$ rm protected/test 
rm: remove write-protected regular empty file `protected/test'? y
rm: cannot remove `protected/test': Permission denied

And if you try to remove the directory:

$ rm -R protected
rm: descend into write-protected directory `protected'? y
rm: remove write-protected regular empty file `protected/test'? y
rm: cannot remove `protected/test': Permission denied
share|improve this answer

Set the owner and group of the file to root and make it world readable:

chown root:root filename
chmod 664 filename
share|improve this answer
1  
That won't work, because the user has write permissions on its directory. It's still able to modify the directory, thus removing files, no matter who owns it. –  Bram Schoenmakers May 27 '10 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.