I execute the script below as root within MAC OS X terminal. The piped command runs successfully, but the script fails at the chown command with the following error:
chown: Domain Users: illegal group name
Why?
See script below:
#!/bin/bash
echo Enter username
read Name
echo Enter number
read NUM
sudo -s "(cd /Users/$NAME && tar c .) | (cd /Users/$NUM && tar xf -)"
sudo chown -R $NUM:"Domain Users" /Users/$NUM
sudo chmod g+rwx /Users/$NUM
"Domain Users" is an Active Directory group, hence one must be connected to the domain in order to CHOWN against a specified user within this group and take ownership of the resources specified. I was working remotely this day and was not connected via our VPN, hence not connected to our domain and thus unable to CHOWN against this Active Directory group "Domain Users".