brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dscl . -read shows how macOS stores your user account

macOS
~/tips/tip-macos-dscl-read-user

dscl . -read /Users/$USER NFSHomeDirectory UserShell UniqueID

Read your account's home folder, shell and user ID straight from the directory.

A Mac has no /etc/passwd that tells the real story about local users. The account data sits in Directory Services, and dscl reads it.

The dot means the local directory. Ask for your own record and only the attributes you care about:

dscl . -read /Users/$USER NFSHomeDirectory UserShell UniqueID

You get your home folder, your login shell and your numeric user ID. The first account on a Mac usually has ID 501, which is also the number you see in file listings with ls -n.

Leave the attribute names off and you get the whole record, which is long. To see all local accounts, including the many hidden system accounts whose names start with an underscore:

dscl . -list /Users UniqueID

I’d reach for it when a shell change didn’t seem to stick, or to check a user’s ID before setting up file sharing with a NAS, where matching IDs avoid permission trouble.

Stick to -read and -list unless you know what you’re doing. dscl can also create, change and delete records, and with sudo it will happily edit an account in a way that locks it out. For normal changes, such as a new login shell, use chsh or the Users & Groups settings.

Further reading: dscl.1 man page

More macOS tips System Settings > Accessibility > Hover Text > When using the pointer A Smart Folder in Notes collects notes by tag, checklist or date Type # in a Mac note to tag it, then filter by tag in the sidebar tmutil isexcluded ~/Projects/app/node_modules Crop an image in Preview by dragging a frame and clicking Crop All macOS tips (99) All topics

Link