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
4 replies

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"

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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