LinuxQuestions.org
Review your favorite Linux distribution.
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 01-03-2008, 02:03 PM   #1
dfodor
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
directory attribute - protect from deleting?


Hi!

I would like to make a directory that (and maybe its content) can not be deleted but files can be copied into it. The best solution would be chattr +a Directory but it does not work.

I create the directory (e.g., backup), and type chattr +a backup. It works so far:

lsattr -d backup
-----a------------ backup

When I try to copy a file into it I get an error message:

cp: cannot create regular file `***': Operation not permitted

The file is created but its size is 0.
The +u attribute does not work at all, I can delete both directories and files with this attribute.

I also created a directory and changed the ownership to root.user and set the permissions to 770 but user also can delete the directory.

I have ext3 file system and use ubuntu 7.10

Does anyone have a tip?

Cheers

Daniel
 
Old 01-03-2008, 02:15 PM   #2
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 308

Rep: Reputation: Disabled
if your worried that another user might delete it make it hidden ie ad a " . " to the front of the folder name

edit also i dont think an average user can delete files in /root but youll need to sudo in order to copy to it

Last edited by tommytomthms5; 01-03-2008 at 02:17 PM.
 
Old 01-03-2008, 02:57 PM   #3
dfodor
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Hi!

Thanks for your reply.
It is technically interesting for me. I am trying to make a home network with 2-3 PC-s and want to make some directories that cannot be (accidentally) removed. I am not afraid of another users but only want to make it 'child safe'.

Daniel
 
Old 01-03-2008, 07:07 PM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
You may want to try looking at the 'Immutable' flag. Say I create a file and place this attribute on it. Now root cannot even remove it until said flag is removed. You may also be interested in the 'sticky bit' which allows a shared directory to be world-writable, but the files therein can only be removed by the users who put them there, if that makes sense.

You can search the LQ forums for more information on both of these terms and, failing that, Google.

Best of luck!
 
  


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
Protect directory Blisk Linux - Security 2 12-03-2007 04:22 PM
How to protect a file/directory in your home login directory (RH Linux) jitsenho Linux - Security 9 07-04-2006 12:08 AM
remove read only attribute in user's directory dsholden Linux - Newbie 5 09-14-2005 06:10 PM
Need to protect a directory wayloud *BSD 1 10-13-2004 05:02 PM
using apache to protect a directory Syncrm Linux - Networking 0 08-31-2001 05:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:08 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
Open Source Consulting | Domain Registration