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 1

    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
      cpio can be called an “alternative” to cp with a very big stretch ... first of all, it’s still a utility for working with archives, and the pass-through mode is still designed to prepare these. - Fat-Zer