~/Library/Saved Application State/
# 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
$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)'
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
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 - -- -