3

How can i get my apple id via terminal command?

I tested dscl command in my terminal with the following parameters?

  1. dscl . -list /Users AppleID
    
  2. dscl . -list /Users UniqueID
    

But i didn't get anything with these commands. I need to get my apple id via command line.

Any suggestion?

2
  • apple.stackexchange.com/questions/256013/… Commented May 16, 2021 at 16:56
  • I support it depends in which section of the OS or app you enter your AppleID - there are quite a few places it can be used and you don’t have to use the same ID across all the locations…
    – bmike
    Commented May 16, 2021 at 19:49

3 Answers 3

4

The information about the currently logged in Apple ID can be retrieved with the following command: defaults read MobileMeAccounts Accounts Alternatively, you can take a look at the tool mas-cli. With the command mas account you can also query the Apple ID.

3
3

I improved @rollcoaster answer as bellow :

user$ defaults read MobileMeAccounts Accounts | grep AccountID | cut -d \" -f2

The output of defaults read MobileMeAccounts Accounts statement is a json, so i applied grep command on this json to get AccountID field. Finally i extracted the content of quoted string from the output.

1
  • 1
    You can use PlistBuddy under /usr/libexec/PlistBuddy with a simple XPath-like query syntax for that: /usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" ~/Library/Preferences/MobileMeAccounts.plist
    – cachius
    Commented Jun 13, 2023 at 18:16
3

I found a way to get my apple id. There's a file named my apple id in the following path:

ls ~/Library/Application\ Support/iCloud/Accounts/ | grep @

This is the output:

[email protected]

There's two files in the ../Account directory and i have to filter them and separate them with @ sign, because an apple id has @ sign within itself.

You must log in to answer this question.

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