To create an account in the Users folder
dscl / -create /Users/addfromcli
Create and set the shell property to bash.
dscl / -create /Users/addfromcli UserShell /bin/bash
Create and set the user’s full name. (Displayed in some of the panels/login screen)
dscl / -create /Users/addfromcli RealName "Added From Cli"
Create and set the user’s ID. (this is the unique id, you need to find out what id your last user create was and add one)
dscl / -create /Users/addfromcli UniqueID 503
Create and set the user’s group ID property. (This can be your default group)
dscl / -create /Users/addfromcli PrimaryGroupID 1000
Create and set the user home directory.
dscl / -create /Users/addfromcli NFSHomeDirectory /Local/Users/addfromcli
Set the password. (dont use password as a password)
dscl / -passwd /Users/addfromcli PASSWORD
Some more details can be found on OS X Daily
Wish I could claim credit for this one, but I found it buried in https://github.com/chcokr/osx-init/blob/master/install.sh
This worked on my 10.10 headless VM without a logged in UI. Updates applied for compatibility with at least 10.9-10.14
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
softwareupdate -i "$PROD" --verbose
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
This presumes you only have 1 result to
softwareupdate -l | grep "\*.*Command Line"
- if this returns multiple versions, you might need more specific logic. (I dont have a repro case)
one variation that seems to work (limited testing) on 10.10-10.14 (10.9 doesn't return an osx version number in the cli tools name..so this doesn't work there):
PROD=$(softwareupdate -l |
grep "\*.*Command Line.*$(sw_vers -productVersion|awk -F. '{print $1"."$2}')" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
a few example results:
* Command Line Tools (OS X Mavericks)-6.2
* Command Line Tools (OS X 10.10) for Xcode-7.2
* Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2
* Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1
* Command Line Tools (macOS Mojave version 10.14) for Xcode-10.1
Best Answer
You could also create an Automator workflow with just an empty New Reminders Item action and then run it with
automator -i title test.workflow
.See also this post at Mac OS X Hints.