Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Mac OS X – Remove Users In Terminal/SSH

Posted on February 19, 2016March 30, 2016 By David Kittell

Recently I had to remove users from a Mac that was on a network only with SSH available.

In this document I use the user name “administrator” as the account that I do the work in and would like to keep, your user name may be different.

First we need to enable root

dsenableroot

This will ask for a user name and password of an admin user then ask to create a root password and have you confirm it.

When done correctly you will see “dsenableroot:: ***Successfully enabled root user.”

Next we want to remove the users, note this will only remove the user access and not the files for that user.

sudo dscl . delete /users/Guest
sudo dscl . delete /users/jdoe1
sudo dscl . delete /users/jdoe2
sudo dscl . delete /users/marketing

OPTIONAL: Force the startup video to play again for the first login

sudo rm -r /var/db/.AppleSetupDone

Now we will move, not delete, all of the previous user files into a directory we can easily access should we need them later. This is important if you don’t really know what people were storing.

mkdir /users/administrator/Desktop/OldUserFiles/
sudo mv /users/Guest /users/administrator/Desktop/OldUserFiles/
sudo mv /users/jdoe1 /users/administrator/Desktop/OldUserFiles/
sudo mv /users/jdoe2 /users/administrator/Desktop/OldUserFiles/
sudo mv /users/marketing /users/administrator/Desktop/OldUserFiles/

When done disable root

dsenableroot -d

This will ask for a user name and password of an admin user.

When done correctly you will see “dsenableroot:: ***Successfully disabled root user.”

References:
Enable Root: OSXDaily.com

Originally Posted on February 19, 2016
Last Updated on March 30, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Mac OS X Shell Mac OSX UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

Mac OS X – Get Network Information

Posted on February 27, 2017May 2, 2017

Every once in a while you need to get some basic network information from your Mac or a Mac you are supporting, this script below will help get you some helpful information. #!/bin/sh clear sExternalMACALService="http://dns.kittell.net/macaltext.php?address=" # List all Network ports NetworkPorts=$(ifconfig -uv | grep ‘^[a-z0-9]’ | awk -F : ‘{print…

Read More

Mac OSX – Terminal – Install Gulp

Posted on May 4, 2018

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install node #npm config set registry http://registry.npmjs.org/ npm install –global gulp-cli All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully…

Read More

Calculate BMI

Posted on April 16, 2014October 26, 2015

static int CalculateBMI(int weight, int height) { return (weight * 703) / (height * height); } Originally Posted on April 16, 2014Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes