Creating a user from the command line
Used in conjunction with a modular disk imaging solution this guide explains the basics to create a new user from the command line. The code can be used as a first run script, distributed through Apple Remote Desktop etc.
The “Directory Service command line utility” dscl allows creation and management of user records in Mac OS X. The example below creates a user called “Local Administrator” with a short name of “ladmin”. To set a secure password via a hash file is outlined at the end of the guide.
Create the user (via the short name)
dscl . -create /Users/ladmin
Set the user shell
dscl . -create /Users/ladmin UserShell /bin/bash
Set the user real name
dscl . -create /Users/ladmin RealName "Local Administrator"
Set the user unique ID remembering it must be unique. If you set an ID below 500 and use the “hide 500 users” login window default (defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool TRUE) you can create hidden – to the average person – users.
dscl . -create /Users/ladmin UniqueID 510
Set group ID (20 is “Staff”)
dscl . -create /Users/ladmin PrimaryGroupID 20
Set home directory
dscl . -create /Users/ladmin NFSHomeDirectory /Users/edadmin
Set a password temporarily (as an encrypted password will be put in place so it is not stored in plain text)
dscl . -passwd /Users/ladmin temppassword
Set a password hint
dscl . -append /Users/ladmin AuthenticationHint "No hints!"
Finally add the user to admin group (or not in the case of a standard user)
dscl . -append /Groups/admin GroupMembership ladmin
and the _lpadmin group (so that printers can be controlled)
dscl . -append /Groups/_lpadmin GroupMembership ladmin
If a default home directory has been copied in place theĀ ownership will need to be changed to the newly created user. To use this script in a modular disk image solution such as InstaDMG the home directory could be “installed” via a package. If you want a default home folder from the machine do not worry about this step.
chown -R ladmin "/Users/ladmin/"
Setting the password
To keep the password secure as the script is stored in plain text, copying an encrypted password hash file from /var/db/shadow/hash/ of a user on another computer with the desired password will keep it out of plain sight. Once copied to the new computer the hash needs to be renamed to the GUID of the new user.
To find the GUID of the new user
dscl . -read /Users/ladmin GeneratedUID
This will output the GUID that can then be used to remove the existing temporary hash and move the real password hash in place. The following example assumes the the hash file is located in /tmp/usercreate/ as ladmin_hash).
rm /var/db/shadow/hash/GUID_NUMBER_HERE
mv /tmp/usercreate/ladmin_hash /var/db/shadow/hash/GUID_NUMBER_HERE
Alternatively as a simple script the GUID can be stored in a variable to then copy the new hash into place.
#!/bin/sh
ladminGUID=`/usr/bin/dscl . -read /Users/ladmin GeneratedUID | cut -f2 -d " "`
#remove and place new password hash
rm /var/db/shadow/hash/"$ladminGUID"
mv /tmp/usercreate/ladmin_hash /var/db/shadow/hash/"$ladminGUID"
File permissions for the password hash
-rw------- root wheel

May 28th, 2009 at 2:52 pm
Added line to add the user to the _lpadmin group to control printers on the computer.
July 29th, 2011 at 4:04 pm
Order@Coral.Calcium.Online” rel=”nofollow”>..…
Buygeneric pills…
July 29th, 2011 at 6:59 pm
Purchase@Discount.Coral.Calcium” rel=”nofollow”>..…
Buyit now…
July 29th, 2011 at 7:23 pm
Cheap@Coral.Calcium.Online” rel=”nofollow”>..…
Buygeneric meds…
July 29th, 2011 at 9:04 pm
Buy@Discount.Abana” rel=”nofollow”>..…
Buyno prescription…
July 30th, 2011 at 10:26 am
Cheap@Generic.Abilify” rel=”nofollow”>..…
Buygeneric drugs…
July 30th, 2011 at 11:14 am
Cheap@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..…
Buygeneric pills…
July 31st, 2011 at 9:05 am
Cheap@Acai.Online” rel=”nofollow”>……
Buynow…
August 2nd, 2011 at 4:00 pm
Buy@Coral.Calcium.Online” rel=”nofollow”>……
Buywithout prescription…
August 2nd, 2011 at 4:33 pm
Buy@Cheap.Coral.Calcium” rel=”nofollow”>.…
Buydrugs without prescription…
August 2nd, 2011 at 10:52 pm
Buy@Abana.Online” rel=”nofollow”>.…
Buynow it…
August 3rd, 2011 at 6:06 pm
Cheap@Abilify.Online” rel=”nofollow”>..…
Buynow it…
August 3rd, 2011 at 11:44 pm
Cheap@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>……
Buygeneric meds…
August 4th, 2011 at 4:58 am
Buy@Acai.Online” rel=”nofollow”>……
Buyno prescription…
August 4th, 2011 at 5:00 am
Buy@Acai.Online” rel=”nofollow”>.…
Buyit now…
August 4th, 2011 at 5:35 am
Buy@Cheap.Acai” rel=”nofollow”>……
Buygeneric drugs…
August 4th, 2011 at 6:58 am
Buy@Cheap.Acai” rel=”nofollow”>……
Buygeneric drugs…
August 4th, 2011 at 7:51 am
Buy@Discount.Acai” rel=”nofollow”>……
Buyit now…
August 4th, 2011 at 12:23 pm
Order@Discount.Acai” rel=”nofollow”>……
Buynow…
August 4th, 2011 at 5:30 pm
Purchase@Discount.Acai” rel=”nofollow”>……
Buyit now…
August 5th, 2011 at 8:46 am
Order@Acai.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs…
August 5th, 2011 at 6:04 pm
Order@Energy.Boost.Online” rel=”nofollow”>.…
Buygeneric drugs…
August 5th, 2011 at 8:25 pm
Order@Discount.Energy.Boost” rel=”nofollow”>.…
Buynow it…
August 5th, 2011 at 10:40 pm
Purchase@Cheap.Energy.Boost” rel=”nofollow”>.…
Buyno prescription…
August 6th, 2011 at 5:24 am
Buy@Discount.Accupril” rel=”nofollow”>.…
Buyno prescription…
August 6th, 2011 at 2:53 pm
Get@Accupril.Online” rel=”nofollow”>.…
Buygeneric drugs…
August 6th, 2011 at 8:05 pm
Order@Cheap.Accutane” rel=”nofollow”>.…
Buygeneric drugs…
August 7th, 2011 at 7:36 pm
Buy@Aciphex.Online” rel=”nofollow”>.…
Buygeneric pills…
August 9th, 2011 at 2:04 am
Cheap@Aciphex.Without.Prescription” rel=”nofollow”>.…
Buynow it…
August 10th, 2011 at 4:38 pm
Buy@Actonel.Without.Prescription” rel=”nofollow”>.…
Buygeneric meds…
August 11th, 2011 at 8:24 am
Cheap@Actonel.Without.Prescription” rel=”nofollow”>.…
Buyno prescription apx…
August 11th, 2011 at 10:34 am
Purchase@Generic.Actonel.35mg” rel=”nofollow”>..…
Buygeneric drugs krg…
August 11th, 2011 at 8:36 pm
Order@Actos.Online” rel=”nofollow”>..…
Buygeneric pills zdg…
August 12th, 2011 at 4:50 am
Buy@Actos.Without.Prescription” rel=”nofollow”>.…
Buyno prescription luw…
August 12th, 2011 at 6:53 am
Purchase@Generic.Actos” rel=”nofollow”>.…
Buygeneric drugs zfk…
August 12th, 2011 at 8:35 pm
Order@Acular.Online” rel=”nofollow”>..…
Buygeneric meds qmo…
August 13th, 2011 at 8:26 am
Buy@Advair.Online” rel=”nofollow”>..…
Buynow it vhx…
August 14th, 2011 at 7:46 pm
Order@Cheap.Acai” rel=”nofollow”>..…
Buyno prescription gdt…
August 15th, 2011 at 4:57 am
Buy@Acai.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs itj…
August 15th, 2011 at 7:24 pm
Generic@Acai.500mg.Without.Prescription” rel=”nofollow”>..…
Buyno prescription wkp…
August 15th, 2011 at 10:26 pm
Buy@Energy.Boost.Online” rel=”nofollow”>..…
Buynow it cey…
August 16th, 2011 at 5:18 am
Purchase@Energy.Boost.Online” rel=”nofollow”>..…
Buydrugs without prescription faj…
August 16th, 2011 at 10:45 am
accupril@and.muscle.pain” rel=”nofollow”>……
Buynow it zdg…
August 16th, 2011 at 3:41 pm
Order@Cheap.Accupril” rel=”nofollow”>.…
Buynow it fnp…
August 17th, 2011 at 8:29 am
Get@Accupril.Online” rel=”nofollow”>..…
Buyit now irl…
August 17th, 2011 at 12:44 pm
Order@Accutane.Online” rel=”nofollow”>……
Buyit now sge…
August 17th, 2011 at 2:51 pm
Order@Discount.Accutane” rel=”nofollow”>.…
Buygeneric drugs mby…
August 17th, 2011 at 4:51 pm
Purchase@Cheap.Accutane” rel=”nofollow”>……
Buywithout prescription ccw…
August 19th, 2011 at 8:01 am
Buy@Generic.Aciphex.Without.Prescription” rel=”nofollow”>……
Buyit now knc…
August 20th, 2011 at 1:53 am
Buy@Cheap.Acomplia” rel=”nofollow”>……
Buygeneric meds svb…
August 21st, 2011 at 5:13 pm
Purchase@Discount.Acomplia” rel=”nofollow”>..…
Buynow it sgk…
August 22nd, 2011 at 6:06 pm
Buy@Generic.Actonel.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs ouw…
August 22nd, 2011 at 10:06 pm
Order@Actonel.Without.Prescription” rel=”nofollow”>……
Buydrugs without prescription jlg…
August 22nd, 2011 at 11:26 pm
Buy@Cheap.Advair” rel=”nofollow”>.…
Buygeneric drugs hwi…
August 23rd, 2011 at 7:38 pm
Purchase@Advair.Online” rel=”nofollow”>..…
Buyno prescription jui…
August 24th, 2011 at 11:38 am
Purchase@Generic.Advair” rel=”nofollow”>.…
Buynow it lmg…
August 24th, 2011 at 8:58 pm
Buy@Generic.Advair.25mcg50mcg.25mcg125mcg.25mcg250mcg.50mcg500mcg.50mcg100mcg.50mcg250mcg” rel=”nofollow”>..< …
Buydrugs without prescription hak…
August 24th, 2011 at 10:18 pm
Buy@Generic.Advair.25mcg50mcg.25mcg125mcg.25mcg250mcg.50mcg500mcg.50mcg100mcg.50mcg250mcg” rel=”nofollow”>..< …
Buyno prescription lka…
August 25th, 2011 at 5:42 am
< a href="http://trig.com/advair5771/biography/?ml=Advair-25mcg/50mcg-25mcg/125mcg-25mcg/250mcg-50mcg/500mcg-50mcg/100mcg-50mcg/250mcg-Without-Prescription Advair@25mcg50mcg.25mcg125mcg.25mcg250mcg.50mcg500mcg.50mcg100mcg.50mcg250mcg.Without.Pr…
Buydrugs without prescription ygy…
August 25th, 2011 at 7:02 am
Buy@Aggrenox.Online” rel=”nofollow”>..…
Buygeneric drugs ajd…
August 27th, 2011 at 12:06 pm
aciphex@cancer.buy” rel=”nofollow”>..…
Buygeneric drugs…
August 27th, 2011 at 4:06 pm
advair@copd.advertising.campaign” rel=”nofollow”>..…
Buynow…
August 28th, 2011 at 9:26 am
buy@amoxicillin.500mg” rel=”nofollow”>.…
Buynow it…
August 28th, 2011 at 8:38 pm
can@you.get.acai.berries.in.the.grocery.store” rel=”nofollow”>.…
Buydrugs without prescription…
August 29th, 2011 at 4:08 pm
..…
Buyit now…
August 29th, 2011 at 11:46 pm
arimidex@or.nolvadex.steriods” rel=”nofollow”>..…
Buywithout prescription…
August 30th, 2011 at 2:26 am
buy@real.strong.armour” rel=”nofollow”>.…
Buydrugs without prescription…
August 30th, 2011 at 4:02 am
artane@bending.over” rel=”nofollow”>.…
Buynow…
October 18th, 2011 at 1:34 pm
mike divorce cancer tiffany…
Buy_generic pills…
October 19th, 2011 at 7:10 pm
boulder valley asthma and allergy clinic…
Buy_no prescription…
October 20th, 2011 at 1:50 am
steroids abuse sexual dysfunction…
Buy_it now…
October 20th, 2011 at 5:10 am
hiv aids in california in 1997…
Buy_generic pills…
October 20th, 2011 at 6:50 am
impact rating journal of clinical psychology…
Buy_now it…
October 21st, 2011 at 9:22 pm
viagra in the uk…
Buy_no prescription…
October 23rd, 2011 at 1:42 am
what are three effects of obesity…
Buy_it now…
October 23rd, 2011 at 5:46 am
arimidex and marathon…
Buy_generic drugs…
October 25th, 2011 at 5:03 pm
red wine and lipitor…
Buy_no prescription…
October 25th, 2011 at 8:23 pm
good and bad drugs…
Buy_without prescription…
October 25th, 2011 at 10:03 pm
is hepatitis b contagious…
Buy_generic pills…
October 26th, 2011 at 4:43 am
drug rehab center british columbia…
Buy_generic drugs…
October 26th, 2011 at 6:03 pm
follistim increase estradiol levels…
Buy_generic drugs…
October 28th, 2011 at 12:03 am
effexor xr 75…
Buy_generic pills…
October 28th, 2011 at 6:43 am
genital erection…
Buy_now it…
October 28th, 2011 at 8:23 am
low fat diets history…
Buy_drugs without prescription…
October 29th, 2011 at 1:03 am
terbutaline autism claim…
Buy_no prescription…
October 29th, 2011 at 2:43 am
iv zofran…
Buy_drugs without prescription…
October 29th, 2011 at 11:36 pm
hives rash from coming off prednisone…
Buy_generic drugs…
October 31st, 2011 at 9:40 am
does birth control control moods…
Buy_generic drugs…
October 31st, 2011 at 12:59 pm
chf vs pulmonary edema…
Buy_generic drugs…
November 1st, 2011 at 12:20 pm
weight loss tricks for 40 somethings…
Buy_drugs without prescription…
November 1st, 2011 at 7:00 pm
what is metoprolol succinate used for…
Buy_it now…
November 2nd, 2011 at 3:20 am
zocor and ms…
Buy_it now…
November 2nd, 2011 at 10:00 am
adderall then tylenol pm…
Buy_generic drugs…
November 2nd, 2011 at 3:00 pm
abdominal pain lutenizing hormone…
Buy_generic drugs…
November 3rd, 2011 at 1:00 am
ic tramadol hcl 50 mg…
Buy_generic meds…
November 3rd, 2011 at 4:20 am
asthmatic inhaller mask for children…
Buy_it now…
November 3rd, 2011 at 4:00 pm
hypertension police ma…
Buy_drugs without prescription…
November 4th, 2011 at 4:06 pm
hot dog hospital diet substitutions…
Buy_generic drugs…
November 4th, 2011 at 9:06 pm
psychostimulant treatment of depression…
Buy_drugs without prescription…
November 5th, 2011 at 12:26 am
copd lung sounds…
Buy_it now…
November 5th, 2011 at 9:23 pm
images of tongue cancer…
Buy_generic meds…
November 7th, 2011 at 9:43 pm
allergic reaction to topical miconazole…
Buy_generic meds…
November 8th, 2011 at 2:43 am
azithromycin doxycycline over the counter…
Buy_generic pills…
November 8th, 2011 at 4:23 am
forensic drug test swab…
Buy_no prescription…
November 9th, 2011 at 5:57 pm
twin pregnancy obstetrician specialist dallas…
Buy_drugs without prescription…
November 10th, 2011 at 3:57 am
psychotic depression and philadelphia…
Buy_generic meds…
November 10th, 2011 at 5:37 am
shampoo for people with dog allergies…
Buy_now…
November 12th, 2011 at 4:17 am
menopause thyroid cancer…
Buy_without prescription…
November 12th, 2011 at 10:57 am
how to make glucose water…
Buy_it now…
November 12th, 2011 at 2:17 pm
dr loss phil ultimate weight…
Buy_no prescription…
November 13th, 2011 at 1:57 am
boniva and bone thinning and breaks…
Buy_now it…
November 13th, 2011 at 3:17 pm
hormone shot for prostate cancer…
Buy_generic drugs…
November 14th, 2011 at 7:57 am
tobacco alternatives herbal…
Buy_generic drugs…
November 16th, 2011 at 6:55 am
free fast diet tips…
Buy_generic meds…
November 17th, 2011 at 1:15 am
black molley slang drug name…
Buy_generic drugs…
December 10th, 2011 at 3:48 am
depo@provera.bone.loss” rel=”nofollow”>……
Buygeneric drugs…
December 10th, 2011 at 6:05 pm
children@prozac.buy” rel=”nofollow”>……
Buywithout prescription…