Is there a usermod equivalent in terminal for OS X 10.6.1

17

3

Can anyone tell me how to modify a user and add them to a group in terminal on SL (10.6.1)?

It seems that usermod is not used by Mac.

ricbax

Posted 2009-10-25T00:37:27.130

Reputation: 4 894

Answers

9

dscl is the usual way to modify any stuff from Directory Services (whether local or remote) from the command line. See the dscl manpage for all the info (or the local one if you are not running 10.6). Google turns up many examples of how to use it (including many from macosxhints.com).

Chris Johnsen

Posted 2009-10-25T00:37:27.130

Reputation: 31 786

12

Adding a user:

dscl . append /Groups/admin GroupMembership usershortname

Removing a user: (from the group not the system)

dscl . delete /Groups/admin GroupMembership usershortname

Reading the membership of the admin group:

dscl . read /Groups/admin GroupMembership

ricbax

Posted 2009-10-25T00:37:27.130

Reputation: 4 894

2

To add an example, this is how you can modify someones homedirectory:

dscl . -create /Users/postgres NFSHomeDirectory /opt/local/var/db/postgresql84

You can see also properties for an object using the read command:

dscl . -read /Users/postgres

Wichert Akkerman

Posted 2009-10-25T00:37:27.130

Reputation: 121

1

You're correct, these commands are not included in OSX. Although there is a port of adduser for Mac, so you can add a user and change their groups from the command line. Command info here.

John T

Posted 2009-10-25T00:37:27.130

Reputation: 149 037

I am looking more so for the modifying a user and adding them to a specific group – ricbax – 2009-10-25T01:12:52.090

this tool can do both. – John T – 2009-10-25T02:06:04.430