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 OSX Terminal – Create New Admin User

Posted on December 8, 2017 By David Kittell
#!/bin/sh

#  CreateAdminUser.sh
#
#  Created by David Kittell on 12/8/17.
#

clear

userFullName=$1
userName=$2
userPassword=$3

echo "Checking If User Exists"

# List Local Users
# dscl . list /Users | grep -v '_'

if [[ $(dscl . list /Users) =~ "$userName" ]]; then
  echo "User Exists"
else
  echo "User Does Not Exist"

  maxid=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
  #echo $maxid
  newid=$((maxid+1))
  #echo $newid

  sudo dscl . -create /Users/$userName
  sudo dscl . -create /Users/$userName UserShell /bin/bash
  sudo dscl . -create /Users/$userName RealName "$userFullName"
  sudo dscl . -create /Users/$userName PrimaryGroupID 1000
  sudo dscl . -create /Users/$userName UniqueID $newid
  sudo dscl . -append /Groups/admin GroupMembership $userName
  sudo dscl . -create /Users/$userName NFSHomeDirectory /Local/Users/$userName
  sudo dscl . -passwd /Users/$userName "$userPassword"
fi
sudo sh CreateAdminUser.sh "Test User" "lUser" "SomethingSecret"
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

Get Number Of Rows Deleted

Posted on August 1, 2013October 26, 2015

DELETE FROM Files WHERE FileID = 1 SELECT @@ROWCOUNT AS DELETED; Originally Posted on August 1, 2013Last 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 (non-development) system it is suggested…

Read More

Ektron API – GetUserGroup

Posted on February 21, 2013October 26, 2015

public static int GetUserGroup(int userID, string GroupID) { int inGroup = 0; string UsersGroups = ""; if (userID != 0) { Ektron.Cms.API.Common CommonApi = new Ektron.Cms.API.Common(); Ektron.Cms.API.User.User UserAPI = new Ektron.Cms.API.User.User(); Ektron.Cms.GroupData GroupData = new Ektron.Cms.GroupData(); //Number of Provider(" + System.Convert.ToString(UserAPI.GetUserGroupByName("<GROUP NAME>").GroupId) + ") Users: " + System.Convert.ToString(UserAPI.GetUserGroupByName("<GROUP NAME>").UserCount); Ektron.Cms.GroupData[]…

Read More

Install Apps From SDCard

Posted on June 25, 2013October 26, 2015

cd /sdcard/apk for app in *.apk; do pm install -r $app; done Originally Posted on June 25, 2013Last 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 (non-development) system it is…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

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
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes