Reading user Plist files from /var/db/dslocal/nodes/Default/users
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.
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.
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.
Solution 1:
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.