1

Following is the scenario. There are multiple files in a directory created by users belonging to same unix group.

Unix Group: Prod. User in Prod Unix Group: User1 User2 User3.

All 3 users have same privileges.

Scenario 1 If user3 wants to become owner of the files created by user1 and user2 by preserving datetime stamp what is the command user3 needs to execute?

Scenario 2 Can user copy/move the same file in same directory by preserving datetimestamp? What is the command for it?

Scenario3: I tried touch command for the file created by User1. Ownership is changed however timestamp is updated too. Is there a way that timestamp remains the same using touch command?

Thanks.

Jolly J
  • 21
  • 2

1 Answers1

2

Only root can change ownership of files, so user3 will need to be able to use sudo to change ownership of files belonging to user1 and user2.

mv will always preserve all metadata, including modification time and user and group ownership. cp -p will try to preserve all these, but as stated above you can't create files with owner other than yourself, so user and group ownership of files copied with cp -p won't be preserved if you're not already the owner.

touch is designed to change the modification time. I do not see how using touch can change the ownership, I would like to see steps how to reproduce what you saw. However you can use touch --reference=filename filename to preserve the modification time, but it would be useless as it would actually not do anything.

wurtel
  • 3,806
  • 12
  • 15