How to copy or move a file or folder in the Linux terminal using the mv or cp commands so that if they transfer, they will have a different owner and group ?
1 answer
cp does not support changing ownership when copying. You can change the owner of the file after copying: cp srcfile /home/user/Documents ; chown user:user /home/user/Documents/srcfile cp srcfile /home/user/Documents ; chown user:user /home/user/Documents/srcfile . If you just want to change the owner and copy one command, read about the utility cpio - an alternative to cp .
- one
cpiocan be called an “alternative” tocpwith a very big stretch ... first of all, it’s still a utility for working with archives, and thepass-throughmode is still designed to prepare these. - Fat-Zer
|