Digital Impermanence
Digital Impermanence

Reputation: 417

BASH chown command not executing from script: illegal group name

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

Upvotes: 1

Views: 4857

Answers (2)

Digital Impermanence
Digital Impermanence

Reputation: 417

"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".

Upvotes: 3

ptierno
ptierno

Reputation: 10074

Your reading the variables wrong:

should look like this:

...
read NAME
....
read NUM

Upvotes: 0

Related Questions