Find the answer to your Linux question:
Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By ibelieveme
A file has the right to read write and execution,but can't be deteled!!!...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    30

    file permission question


    A file has the right to read write and execution,but can't be deteled!!!
    Lakshmipathi likes this.

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,769
    If you are using ext{2,3,4} file system - then you can set the immutable flag.
    #sudo chattr +i file.txt
    # rm file.txt
    rm: remove regular file `file.txt'? y
    rm: cannot remove `file.txt': Operation not permitted
    The file can't be deleted along as the attribute is not removed using the command "chattr -i file.txt".

    HTH
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  3. #3
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    30
    Thank you for your answer,but you do not understand what I mean, changing attribute after string "This is word" write failure.
    [root@skyxue ~]# touch file.txt
    [root@skyxue ~]# chattr +i file.txt
    [root@skyxue ~]# echo "This is word" > file.txt
    -bash: file.txt: Permission denied

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,769
    I think,now I understand it . Instead of setting chattr to file do that to the directory
    #mkdir dir
    #mv file.txt dir
    #chattr +i dir
    Now you can read/write the existing file but can't remove or create new file with dir
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  6. #5
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    30
    you're right ,Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •