OSX chown problems after creating users with dscl

chownmac-osx

Alright, so I've made a user and a group using dscl as follows:

dscl . -create /Users/deadline
dscl . -create /Groups/deadline
dscl . -append /Groups/deadline GroupMembership deadline

Now I'm trying to chown things like so:

mkdir /tmp/stuff
chown deadline:deadline /tmp/stuff

But the problem is that it sets the user and group to nobody instead of this user 'deadline'. What magic voodoo property do I need to add to the user and group to have it set the unix permissions properly?

Also, why must Apple hate me and my Unix background 🙁

Best Answer

You created the user record, but didn't give it any settings so it's using defaults.

sudo dscl . -append /Groups/deadline PrimaryGroupID 100
sudo dscl . -append /Users/deadline UniqueID 1000 PrimaryGroupID 100

You might want to look at the output of things like:

dscl . -read /Users/$USER
dscl . -read /Groups/admin

to see what attributes can be set.

Related Topic