Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    question about file deletion

    Someone asked a question that after I looked into it didn't work as I would have guessed,so I'm here asking the question.

    If I create a file in mydir BUT I create it as root ,why can I delete it??
    It has a root root group/owner permission so I would have thought that only root could delete it, BUT when I logon as myself I can delete it



  2. #2
    Linux Enthusiast
    Join Date
    Apr 2004
    What you can and can't do to a file is determined by the permissions on the file and the containing directory.

    In order to delete a file you have to have write permissions for the containing directory. This does make sense because if you were to access the file after it had been deleted (say by making an extra hard link to the file) you'd see it was unchanged. What you are actually changing is the contents of the containing directory so you need write permisisons there. There is one caveat to this whereby you can set the directory permissions so others can write to the directory but only the directory owner can delete.

    more information can be found here

    Let us know how you get on,

    To be good, you must first be bad. "Newbie" is a rank, not a slight.

Posting Permissions

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