Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I list all local user accounts (whether logged in or NOT so 'users' or 'who' is no good) in the terminal on a mac? OS X version is 10.6.8.

I have seen this suggested - dscacheutil -q group

But it lists domain user groups and non-local accounts.

share|improve this question
1  
As a long time AIX user, I sure miss the system management commands they baked into their unix. lsuser would be nice to have for this purpose. –  bmike Nov 1 '11 at 14:25

5 Answers 5

up vote 15 down vote accepted

How about

dscacheutil -q user | grep -A 3 -B 2 -e uid:\ 5'[0-9][0-9]'
share|improve this answer
    
I like this option. It returns a bunch of accounts beginning with an underscore, though. Any way to filter this out? e.g. _softwareupdate, _mysql –  codecowboy Nov 1 '11 at 14:13
3  
Pipe the result through grep dscl . list /Users | grep -v ^_.* –  Mark Nov 1 '11 at 14:20
    
Very cool! I'll have to remember this one. –  daviesgeek Nov 9 '11 at 21:58
    
This is such an easy one to commit to memory, too. –  Kelly Jul 26 '13 at 22:58

If no user home directories were moved then ls /users will do. Except it will also list directories like 'Shared'.

share|improve this answer

Try this one. i used it to find lost hidden account.

dscl . list /Users | grep -v ^_.*
share|improve this answer
1  
That's precisely what @Mark said here. –  Emil Feb 9 '13 at 12:36

dscacheutil returns more than just local users, for example any users I've queried directory services for also show. I have found this more useful:

dscl . list /Users | grep -v "^_"

although it also returns the likes of daemon, nobody and root

share|improve this answer

Each user should have his home directory in /Users, so can't you just

ls /Users

and then ignore the "shared" directory

share|improve this answer
1  
You can change the home directory so this is not complete –  Mark Nov 1 '11 at 14:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.