I executed those two commands in terminal:
users
and
dscl . -read /Users/
and then they tell me two different results. The second one gave me a long list while the first one just showed my username on Mac.
When I google for "List users on Mac", most will tell me use the second one. However when I execute "man users", it shows me that this command is to "list current Users".
Could you tell me the differences?
Also, how do I execute a command as mysql user. The following command didn't work:
mkdir mysqldir --user mysql
Best Answer
dscl . -read /Users/
doesn't print anything particularly interesting; you probably meandscl . -ls /Users
, which prints a list of user accounts that are defined on your computer (including a great many normally-hidden system accounts).users
, on the other hand, prints a list of users who are currently logged in on your computer (usually just you).For your second question: you can use the
sudo
command to run commands as another user (e.g.sudo -u _mysql mkdir mysqldir
). Note that this requires admin rights, and will ask you to enter your password for verification.