Command Line Permissions – Create Nested Directories with Same User/Group in Single Command

command linepermissions

Is there a way to create nested directories which all have the same user/group in a single command?

That single command would have the same effect as the following two commands:

mkdir -p new-1/new-2/new-3
chown -R myUser:myUser new-1

Best Answer

I can not add a comment, therefore I post this as an answer. Have a look at install, see man install(1).

install -d -g myUser -o myUser new-1 new-1/new-2 new-1/new-2/new-3

Or, if you don't want to repeat the directory names (using root user):

sudo -g myUser -u myUser mkdir -p new-1/new-2/new-3

Related Question