ashwinsakthi
ashwinsakthi

Reputation: 1956

Change permissions for newly copied file in Unix/Linux

We are using two users for placing the file and reading the file in Unix server.Eventhough i have changed the permissions of the directory to drwxrwxrwx .When User 1 places/copies the file inside the directory the permissions change to -rw-rw----.

So User2 is not able to read the file.User2 is actually my java application which uses the file for processing.

Can anyone provide me a suggestion that when the user1 copies the file also it maintains the attributes of the directory so that User2(My app) can read it without difficulty.

Upvotes: 0

Views: 2025

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328574

  1. The permissions of the directory should be drwxrwx---; You don't want the whole world to mess with the files in there.

  2. You need to give both users a common group (see the admin manual how to create groups and assign users to them). Both users need to login again to make the change visible.

  3. Assign this group to the directory

  4. chmod g+s on the directory tells Linux to give the group to all new files in it.

Upvotes: 3

Related Questions