I have a script running with the user user1:user1
, making operations inside a directory dir
.
At the end of the script, I would like to use chown to change the owner of the script to user2:user2
But it doesn't work. I tried the same operation, logged in as user1 :
$ ls -l
drwxr-xr-x 5 user1 user1 4096 Jan 11 10:58 dir
$ chown -R user2:user2 dir
chown: changing ownership of dir: Operation not permitted
Why can't I change the owner of my own files/repertories ? Is there an other way than using a root access to do this ?
UPDATE
The script makes a git clone and then a rsync with an Apache directory. New files have for owner the current user, but I need Apache to be the owner instead.
chown
a file? on Unix & Linux