1

Identifying user accounts in macOS (Catalina) can be achieved using the following command

 dscl . -list /Users | grep -vE '_|root|nobody|daemon|Guest'

Which gives me the below output.Note: hiddenswasti is a hidden account (not visible in the login/welcome screen) while swastibhushandeb is a normal account. enter image description here

Referring to a post here ,it is inferred that the user specific plist files residing in var/db/dslocal/nodes/Default/users can be read using defaults read or plutil -p and contains valuable information to ascertain if an account is hidden or otherwise. enter image description here

Issue I am facing is to develop a one liner code (using bash )is utilizing the output of the dscl command detailed above and use generated output as input to plutil -p to read the contents of hiddenswasti.plist and swastibhushandeb.plist. Would appreciate help.Thanks in advance.

6
  • 1
    Please copy/paste from Terminal as text (and apply code formatting), screenshots are hard to read.
    – nohillside
    Commented May 28, 2021 at 7:19
  • 1
    Also, if you already know where hiddenswasti.plist is stored, why not just run plutil on it?
    – nohillside
    Commented May 28, 2021 at 7:19
  • Hi @nohillside. dscl command output provides the user account names.We can use that information to look in the var/db/dslocal/nodes/Default/users directory for the accountname.plist. I can do the above two steps in two commands.But was anxious if we can use xargs to do both the operations in one single liner.Hope it clarifies.I tried something like this: bold sudo dscl . -list /Users | grep -vE '_|root|nobody|daemon|Guest'|xargs -0 -n 1 sh -c 'sudo plutil -p /var/db/dslocal/nodes/Default/users/"$1.plist"' _ Commented May 28, 2021 at 13:18
  • 1
    Yes, this should work (if you omit the -0 part)
    – nohillside
    Commented May 28, 2021 at 13:29
  • removing the "-0" really worked.Thanks Commented May 28, 2021 at 14:16

1 Answer 1

3

You can try this to loop through the users.

USER_PLIST="/var/db/dslocal/nodes/Default/users"

for user in $(dscl . -list /Users | grep -vE '_|root|nobody|daemon|Guest'); do 
  sudo defaults read ${USER_PLIST}/${user}.plist
done 

This sets up a for loop with your dscl output and feeds those usernames to defaults. You can easily substitute plutil, if you prefer. You can make this a one-liner by using the semicolon between carriage returns. I left that out to make it easily readable.

HTH.

1
  • Fails in Mojave and probably everywhere: # defaults read /var/db/dslocal/nodes/Default/users/*.plist … Domain /var/db/dslocal/nodes/Default/users/*.plist does not exist — Where * is each and every ${user}
    – Devon
    Commented Dec 17, 2022 at 17:36

You must log in to answer this question.

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