~/Library/Saved Application State/
In case Keychain complains about certificates touched by openssl, make sure to use the system binary and not one installed by the user.
/usr/bin/openssl
# Generate the ppd
/System/Library/Printers/Libraries/ipp2ppd ipp://ipaddress/ipp/print /tmp/test > printer.ppd
# Setup the printer
/usr/sbin/lpadmin -p #{printer_name} -E -D "#{printer_name}" -P "/tmp/test/printer.ppd" -v ipp://ippaddress/ipp/print -L "#{printer_description}" -o printer-is-shared=false 2>&1
- https://github.com/UoE-macOS/jss/blob/master/coreconfig-check-xerox-drivers.sh
- https://github.com/UoE-macOS/jss/blob/master/coreconfig-add-printer.sh
sudo systemsetup -getdate
sudo systemsetup -setdate <mm:dd:yy>
sudo systemsetup -gettime
sudo systemsetup -settime <hh:mm:ss>
sudo systemsetup -listtimezones
sudo systemsetup -gettimezone
sudo systemsetup -settimezone America/Vancouver
#!/bin/bash
uuid=$("/usr/sbin/system_profiler" SPHardwareDataType | grep "Hardware UUID" | awk '{ print $3 }')
timedPrefs="/private/var/db/timed/Library/Preferences/com.apple.timed.plist"
dateTimePrefs="/private/var/db/timed/Library/Preferences/com.apple.preferences.datetime.plist"
locationPrefs="/private/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.${uuid}.plist"
byHostPath="/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd"
# Set preferences.
echo "Ensuring location services are enabled"
sudo -u "_locationd" /usr/bin/defaults -currentHost write "$locationPrefs" LocationServicesEnabled -int 1
sudo defaults write "${byHostPath}" LocationServicesEnabled -int 1
/usr/sbin/chown "_locationd:_locationd" "$locationPrefs"
echo "Configuring automatic time"
/usr/bin/defaults write "$timedPrefs" TMAutomaticTimeZoneEnabled -bool YES
/usr/bin/defaults write "$timedPrefs" TMAutomaticTimeOnlyEnabled -bool YES
/usr/bin/defaults write "$dateTimePrefs" timezoneset -bool YES
/usr/sbin/chown "_timed:_timed" "$timedPrefs" "$dateTimePrefs"
exit 0
- Tested: macOS 14
- Reboot required: Yes for macOS 14.4 since
launchctl
no longer has control over important system processes
defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
$DIR/$ALIAS
->$TARGET
osascript \
-e 'tell application "Finder"' \
-e ' set theTgt to POSIX file "'"$TARGET"'" as alias' \
-e ' make new alias to theTgt at POSIX file "'"$DIR"'"' \
-e ' set name of result to "'"$ALIAS"'"' \
-e 'end tell'
osascript -e 'tell application "Finder" to delete ((POSIX file "<FILE_PATH>") as alias)'
- macOS 10.7+
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0”>
<dict>
<key>PayloadContent</key>
<array>
<dict>
<!-- ... -->
<key>RetriesUntilHint</key>
<integer>0</integer>
<!-- ... -->
<key>PayloadIdentifier</key>
<string>com.example.myloginwindowpayload</string>
<key>PayloadType</key>
<string>com.apple.loginwindow</string>
<key>PayloadUUID</key>
<string>fe9ba3c5-0f1a-45c7-b6df-a5f4489695fe</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</array>
<key>PayloadDisplayName</key>
<string>Login Window</string>
<key>PayloadIdentifier</key>
<string>com.example.myprofile</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>61bd7d63-4a4a-4b67-9112-5ceb16afb4dc</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
defaults write com.apple.loginwindow RetriesUntilHint -int 0
Check out "Directory Utility":/System/Library/CoreServices/Applications/Directory Utility.app
dscl /Local/Default -authonly $USERNAME $PASSWORD
Return code 0
on success, 10
on failure.
Hidden admin user:
LOCAL_ADMIN_FULLNAME="Joe Admin" # The local admin user's full name
LOCAL_ADMIN_SHORTNAME="joeadmin" # The local admin user's shortname
LOCAL_ADMIN_PASSWORD="password" # The local admin user's password
# Create a local admin user account
sysadminctl -addUser $LOCAL_ADMIN_SHORTNAME -fullName "$LOCAL_ADMIN_FULLNAME" -password "$LOCAL_ADMIN_PASSWORD" -admin
dscl . create /Users/$LOCAL_ADMIN_SHORTNAME IsHidden 1 # Hides the account (10.10 and above)
mv /Users/$LOCAL_ADMIN_SHORTNAME /var/$LOCAL_ADMIN_SHORTNAME # Moves the admin home folder to /var
dscl . -create /Users/$LOCAL_ADMIN_SHORTNAME NFSHomeDirectory /var/$LOCAL_ADMIN_SHORTNAME # Create new home dir attribute
dscl . -delete "/SharePoints/$LOCAL_ADMIN_FULLNAME's Public Folder" # Removes the public folder sharepoint for the local admin
USERID=$(dscl . -list /Users UniqueID | awk 'BEGIN { max = 500; } { if ($2 > max) max = $2; } END { print max + 1; }')
dscl . -create /Users/$USERNAME
dscl . -create /Users/$USERNAME UserShell /bin/bash
dscl . -create /Users/$USERNAME RealName "$FULLNAME"
dscl . -create /Users/$USERNAME UniqueID "$USERID"
# 'staff' user group
dscl . -create /Users/$USERNAME PrimaryGroupID 20
dscl . -create /Users/$USERNAME NFSHomeDirectory /Users/$USERNAME
dscl . -passwd /Users/$USERNAME $PASSWORD
dseditgroup -o edit -t user -a $USERNAME admin
createhomedir -c -u $USERNAME > /dev/null
Starting with Catalina, the default UserShell
is /bin/zsh
.
- macOS ??
# dscl . -merge /Users/$USERNAME hint "your password hint"
dscl . -merge /Users/$USERNAME AuthenticationHint "your password hint"
dscl . -read /Users/$USERNAME AuthenticationHint
#!/bin/sh
for userhomedir in /Users/*/
do /usr/bin/dscl . -delete "$userhomedir" AuthenticationHint
done
dscacheutil -q user | grep -A 3 -B 2 -e uid:\ 5'[0-9][0-9]'
dscl . list /Users UniqueID | grep -v '^_'
- macOS: 10.15+
This does not delete the
/Users/<user>
folder.
/usr/bin/dscl . -delete /Users/<user>
sudo dseditgroup -o edit -d <user> -t user admin
User being renamed must not be signed in.
dscl . change /Users/<old> NFSHomeDirectory /Users/<old> /Users/<new>
mv /Users/<old> /Users/<new>
dscl . change /Users/<old> RecordName <old> <new>
See the RenameMacUserNameAndHomeDirectory.sh
below.
#!/bin/sh
user="$1"
image="$2"
dscl . delete "/Users/$user" JPEGPhoto
dscl . delete "/Users/$user" Picture
tmp="$(mktemp)"
printf "0x0A 0x5C 0x3A 0x2C dsRecTypeStandard:Users 2 dsAttrTypeStandard:RecordName base64:dsAttrTypeStandard:JPEGPhoto\n%s:%s" \
"$user" "$(base64 -i "$image")" > "$tmp"
dsimport "$tmp" /Local/Default M
rm "$tmp"
Usage: sudo setUserPicture <user> <image path>
With confirmation:
osascript -e 'tell app "System Events" to log out'
Without confirmation:
ignoring application responses
tell app "System Events" to «event aevtrlgo»
-- OR:
-- tell application "loginwindow" to «event aevtrlgo»
end ignoring
osascript -e 'tell app "System Events" to «event aevtrlgo»'
sudo launchctl bootout "gui/$(id -u <username>)"
# OR
sudo launchctl bootout "user/$(id -u <username>)"
- macOS 10.11.x or later
sudo /Applications/Adobe\ Acrobat\ DC/Adobe\ Acrobat.app/Contents/Helpers/Acrobat\ Uninstaller.app/Contents/Library/LaunchServices/com.adobe.Acrobat.RemoverTool
mdfind kMDItemCFBundleIdentifier = "com.adobe.reader"
pluginkit manages the PlugInKit subsystem for the current user. plugin plug-in extension pluginkit
List all extensions:
pluginkit -m
Enable an extension:
pluginkit -e use -i com.google.drivefs.finderhelper.findersync
Display disk usage statistics.
Size of each user's home directory:
du -h -d 1 -I Library -I .Trash /Users
-I
excludes the directories that usually result in errors
Configuration tool for certain machine settings in System Settings.
man
: Yes- Path:
/usr/sbin/systemsetup
systemsetup -getdate
systemsetup -setdate <mm:dd:yy>
systemsetup -gettime
systemsetup -settime <hh:mm:ss>
systemsetup -gettimezone
systemsetup -settimezone <timezone>
systemsetup -listtimezones
systemsetup -getusingnetworktime
systemsetup -setusingnetworktime <on off>
systemsetup -getnetworktimeserver
systemsetup -setnetworktimeserver <timeserver>
systemsetup -getsleep
systemsetup -setsleep <minutes>
systemsetup -getcomputersleep
systemsetup -setcomputersleep <minutes>
systemsetup -getdisplaysleep
systemsetup -setdisplaysleep <minutes>
systemsetup -getharddisksleep
systemsetup -setharddisksleep <minutes>
systemsetup -getwakeonmodem
systemsetup -setwakeonmodem <on off>
systemsetup -getwakeonnetworkaccess
systemsetup -setwakeonnetworkaccess <on off>
systemsetup -getrestartpowerfailure
systemsetup -setrestartpowerfailure <on off>
systemsetup -getrestartfreeze
systemsetup -setrestartfreeze <on off>
systemsetup -getallowpowerbuttontosleepcomputer
systemsetup -setallowpowerbuttontosleepcomputer <on off>
systemsetup -getremotelogin
systemsetup -setremotelogin <on off>
systemsetup -getremoteappleevents
systemsetup -setremoteappleevents <on off>
systemsetup -getcomputername
systemsetup -setcomputername <computername>
systemsetup -getlocalsubnetname
systemsetup -setlocalsubnetname <name>
systemsetup -getstartupdisk
systemsetup -setstartupdisk <disk>
systemsetup -liststartupdisks
systemsetup -getwaitforstartupafterpowerfailure
systemsetup -setwaitforstartupafterpowerfailure <seconds>
systemsetup -getdisablekeyboardwhenenclosurelockisengaged
systemsetup -setdisablekeyboardwhenenclosurelockisengaged <yes no>
systemsetup -version
systemsetup -help
systemsetup -printCommands
Directory service command line utility.
man
: Yes- Path:
/usr/bin/dscl
Property list utility
man
: Yes- Path:
/usr/bin/plutil
echo "YnBsaXN0MDDRAQJWbW9kdWxl0QMEWHJlbGF0aXZlXxA7ZmlsZTovLy9TeXN0ZW0vTGlicmFyeS9FeHRlbnNpb25LaXQvRXh0ZW5zaW9ucy9GbHVycnkuYXBwZXgICxIVHgAAAAAAAAEBAAAAAAAAAAUAAAAAAAAAAAAAAAAAAABc" | base64 -d -i - | plutil -convert json -o - -- -