Get a list of all users (just their short names):
dscl . -list /Users
Get detailed user info on a particular user:
dscl . -read /Users/<username>
Get a particular value in a user's info:
dscl . -read /Users/<username> <key>
Examples of <key>
are RecordName
, RealName
, UniqueID
, and NFSHomeDirectory
.
Get detailed user info on all users:
dscl . -readall /Users
Get a particular value in all users' info:
dscl . -readall /Users <key>
Hopefully you notice the difference between -list
and -read
. Additional goodies: -plist
outputs as XML, -search
lets you specify a key and value and you will get output indicating where that value is.
2rs2ts:~/ $ dscl . -search /Users RealName "Andrew Garrett" [12:04:07]
2rs2ts RealName = (
"Andrew Garrett"
)
2rs2ts:~/ $ dscl -plist . -read /Users/nobody [12:05:29]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>dsAttrTypeStandard:AppleMetaNodeLocation</key>
<array>
<string>/Local/Default</string>
</array>
<key>dsAttrTypeStandard:GeneratedUID</key>
<array>
<string>FFFFEEEE-DDDD-CCCC-BBBB-AAAAFFFFFFFE</string>
</array>
<key>dsAttrTypeStandard:NFSHomeDirectory</key>
<array>
<string>/var/empty</string>
</array>
<key>dsAttrTypeStandard:Password</key>
<array>
<string>*</string>
</array>
<key>dsAttrTypeStandard:PrimaryGroupID</key>
<array>
<string>-2</string>
</array>
<key>dsAttrTypeStandard:RealName</key>
<array>
<string>Unprivileged User</string>
</array>
<key>dsAttrTypeStandard:RecordName</key>
<array>
<string>nobody</string>
</array>
<key>dsAttrTypeStandard:RecordType</key>
<array>
<string>dsRecTypeStandard:Users</string>
</array>
<key>dsAttrTypeStandard:SMBRID</key>
<array>
<string>501</string>
</array>
<key>dsAttrTypeStandard:UniqueID</key>
<array>
<string>-2</string>
</array>
<key>dsAttrTypeStandard:UserShell</key>
<array>
<string>/usr/bin/false</string>
</array>
</dict>
</plist>
Of course, you can read the man pages to get more info.
dscl . -read /Users/
because I getname: dsRecTypeStandard:Users
which is what I would expect since it's trying to read adsRecType
(which isUsers
in this case, mind).