Is it possible to query the current user's Apple ID from the command line? I want to create an AppleScript (run-only) app that will run only for a specific user (or at least for a user signed in with a specific AppleID), but I can't find any command (or third-party utility) that will do this.

Does something like this exist?


The currently logged in Apple IDs for iCloud are stored in the MobileMeAccounts preferences. You can query the entire store with:

defaults read MobileMeAccounts Accounts

To return just the first account ID (an email address nowadays):

/usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" ~/Library/Preferences/MobileMeAccounts.plist
  • That is exactly what I was looking for. Thank you. One further question: is it possible that there will be more than one Account in the preferences, so that the second of the two commands will return a user who is not currently logged in?
    – emendelson
    Jun 25 '19 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .