0

I have two users in a group.

Users:
   1) apache
   2) data
Group
   1) apache

I have three directories. The directory structure of that three directories are like below.

drwxrwx--- 10 data    apache 4096 Aug 21 14:30 Data
drwxrwx--- 10 data    apache 4096 Aug 21 14:30 App
drwxrwx--- 22 apache    apache 4096 Aug 22 12:04 www

I have a copy program in App directory. It will copy a file from Data directory to www directory. After the copy process over, the copied file are in the mode of below.

----r-----  1 apache apache   35003 Aug 22 11:47 wT89TQsATjE.txt

But I want to be that file permission as like below after the copy process.

-rw-rw----  1 apache apache   35003 Aug 22 11:47 wT89TQsATjE.txt

Could I change the mod of the file to be read as user and group after that copy process automatically?

1

Depending on the permissions before the file is copied, you might copy them with cp -a, which will preserve permissions. This of course means, that your file has to have the permissions -rw-rw---- set before copying.

As a second option, why not change the permissions of the file right after copying:

chmod 660 $copiedFile
  • I thought about it that second option. But the first answer you gave that I want. Thank you. I try to work with that. – Smith Dwayne Aug 22 '18 at 8:30
  • @SmithDwayne do not forget to mark this answer as the solution. – andcoz Aug 22 '18 at 8:56

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.