Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to delete user from terminal in server application

I am running the server application version 5.0.15 and I am wondering how to delete a user from the accounts in the server. I know that you can go in and delete the account in the GUI but I was hoping to automate the processes since I have a lot to do. I was thinking that if I find a terminal command to do it I could create a shell script.

Posted on Jun 12, 2017 12:09 PM

Reply
Question marked as Best reply

Posted on Jun 13, 2017 8:32 AM

Usual rummaging involves first having a full backup (mistakes here are bad), listing out the users, rummaging and viewing as needed, then deleting the target user:


man dscl

dscl . -list /Users

dscl . -read /Users/{target-user-here}

sudo dscl . -delete /Users/{target-user-here}


There are some scripts for this purpose posted around the 'net (that clean up the login directory, etc), but I don't immediately have a pointer to one that I'd recommend.


Related...

macos - How can I delete a Mac OS X Snow Leopard user account from Command Line? - Super User

https://www.apple.com/support/security/guides/docs/SnowLeopard_Server_Security_C onfig_v10.6.pdf

macos - Mac OSX: users vs dscl command to list user - Super User

Hiding user accounts in Yosemite | Der Flounder

http://krypted.com/mac-os-x/create-groups-using-dscl/

http://krypted.com/mac-security/more-group-management-with-dseditgroup/

Edit, Add, And Delete Users With Terminal - YouTube

4 replies
Question marked as Best reply

Jun 13, 2017 8:32 AM in response to Jarrod Rasberry

Usual rummaging involves first having a full backup (mistakes here are bad), listing out the users, rummaging and viewing as needed, then deleting the target user:


man dscl

dscl . -list /Users

dscl . -read /Users/{target-user-here}

sudo dscl . -delete /Users/{target-user-here}


There are some scripts for this purpose posted around the 'net (that clean up the login directory, etc), but I don't immediately have a pointer to one that I'd recommend.


Related...

macos - How can I delete a Mac OS X Snow Leopard user account from Command Line? - Super User

https://www.apple.com/support/security/guides/docs/SnowLeopard_Server_Security_C onfig_v10.6.pdf

macos - Mac OSX: users vs dscl command to list user - Super User

Hiding user accounts in Yosemite | Der Flounder

http://krypted.com/mac-os-x/create-groups-using-dscl/

http://krypted.com/mac-security/more-group-management-with-dseditgroup/

Edit, Add, And Delete Users With Terminal - YouTube

Jun 13, 2017 7:50 AM in response to MrHoffman

Thanks for the reply! However, the users I want to delete are in the LPADv3/127.0.0.1/Users folder. I can access this if I enter dscl and use that mode, but if I try to use dscl . -list /LPADv3/127.0.0.1/Users it says the path does not exist. I think it has something to do with the fact that I can not see the level above the "local" directory. I have tried with out the "." but I just get a "Cannot open remote host, error: DSOpenDirServiceErr"

Jun 13, 2017 8:12 AM in response to Jarrod Rasberry

Edit:

Never mind about that Had a brain fart. I just replaced the "." with "/LPADv3/127.0.0.1/" and it was able to list the /Users properly; however, when I went to use the delete command it gave me a permission error saying "eDSPermissionError." I have tried this with and without sudo while logged into the diradmin through SSH

How to delete user from terminal in server application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.