I have a directory that has the SGID bit set, so ls displays it as drwxr-sr-x, and is owned by a normal user.  I have a file that is owned by root in that directory, with permission 644.   The question is can I make that file become owned by the user-owner of the directory.


You have read permissions of file, and write permission of directory. Therefore you can make a copy, remove original, rename copy to original name.

|improve this answer|||||
  • Thanks @ctrl-alt-delor. That is what I want to know. – koj0k3r94 Jul 22 '19 at 8:50
  • I don’t know of any general, magical way of changing the ownership of an existing file.  If you want to change the owner of the file, you’ll have to chown it (as root, i.e., sudo).
  • The SGID bit a directory has nothing to do with the (user) ownership of files in that directory.  It causes all subsequently (i.e., future) created files in that directory to have the same group ownership as the directory itself.
|improve this answer|||||
  • Thanks for your answer @G-Man – koj0k3r94 Jul 22 '19 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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