Users and Their Environment

logname

Print your login name.

whoami

Print your current, effective username.

id

Print the user ID and group membership of a user.

who

List logged-in users, long output.

users

List logged-in users, short output.

last

Determine when someone last logged in.

finger

Print information about users.

chfn

Change a user’s personal information.

passwd

Change a password.

chsh

Change a user’s shell.

dscl

Create, modify, and delete users.

printenv

Print your environment.

How many user accounts are set up on your Macintosh? For many Mac owners, the answer is “one.”[20] Nevertheless, any Macintosh can have multiple user accounts for family, co-workers, or beloved pets. OS X is a full-fledged multiuser operating system, meaning that multiple people can work a single Macintosh at the same time. While one person is using the connected display, keyboard, and mouse (known as the console), others can log in remotely and run shells and commands (discussed in Running a Shell Remotely). Each user is identified by a unique username, like “smith” or “funkyguy,” and owns a (reasonably) private part of the system for doing work (/Users/smith, /Users/funkyguy, etc.).

This section’s grab-bag of programs tells you all about users: their names, login times, and properties of their environment. Several other commands let you change a user’s password, default shell, and personal details.

[20] Not counting the Guest User, which is installed with OS X.

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.