Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-15-2011, 08:05 AM   #1
LQ Newbie
Registered: May 2011
Posts: 12

Rep: Reputation: Disabled
Create the file, write into that file but can't delete file in Linux

Is it possible to set up permision on the file such owner can create the file & write into that but can not delete file.

Immediate answer highly appreciated
Old 06-15-2011, 08:08 AM   #2
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Yes. Deleting files is dependent on the directory's permissions. So if you set "~/folder" to be read-only, then you can't delete any files inside "~/folder", and if you then set "~/folder/file" to have write permissions, you will have a file that can be written to but not deleted
Old 06-15-2011, 08:11 AM   #3
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
root@CW8:/tmp# touch dir/test.file
root@CW8:/tmp# chown c:users dir/test.file
c@CW8:/tmp/dir$ echo xxx > test.file 
c@CW8:/tmp/dir$ rm test.file
rm: cannot remove `test.file': Permission denied
Old 06-15-2011, 08:45 AM   #4
LQ Newbie
Registered: Apr 2010
Location: Bangalore
Distribution: Redhat, Centos
Posts: 25

Rep: Reputation: 0
Or you can set chattr

chattr +i /path_to_file


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
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM
Linux shell command for to create a text file and write to it alix123 Programming 8 01-07-2005 08:18 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:08 AM.

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