Copy and chmod/chown at the same time

You might want to look at install:

install -g user -o user log.xz /home/user/Documents

install has other options suitable for installing. e.g. set mode or preserve directory structure.


The cp man page does not list any options that would allow you to do this just with the CP command. If you are wanting to just issue a command and "walk away", you can put the 2 commands on 1 line separated by a ; to automatically execute the commands in sequence.

cp log.xz /home/user/Documents ; chown user:user /home/user/Documents/log.xz

see map page of cp command

--preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible addi- tional attributes: context, links, xattr, all

Tags:

Linux

Bash