List Samba users?

142

35

So yesterday evening I was pulling my hair out (figuratively -- I'm bald) for over an hour trying to figure out why smbpasswd kept rejecting my attempts to reset the password for one of my Samba users. Anyway, long story short, it was apparently because the user didn't exist yet (smbpasswd -a added her without complaint, and now everything's hunky-dory), even though I still swear up and down that I did indeed add her already.

Anyway, if I could have simply listed the users in the smbpasswd database, it would saved me a lot of grief. Is there a command or utility that can do that? (Samba's using that new-fangled .tdb database, otherwise I would have just cat /etc/smbpasswd.)

Kromey

Posted 2011-04-14T22:31:27.780

Reputation: 4 377

Answers

192

I believe the command your looking for is pdbedit.

From the man page "pdbedit - manage the SAM database (Database of Samba Users)"

sudo pdbedit -L -v

-L to list users. -v to be verbose.

James T

Posted 2011-04-14T22:31:27.780

Reputation: 8 515

Nope, doesn't work. I get tdbsam_open: Failed to open/create TDB passwd [/var/lib/samba/private/passdb.tdb] – starbeamrainbowlabs – 2016-04-17T16:20:36.357

3@starbeamrainbowlabs I get this error, too, when I run that command WITHOUT sudo! running it with sudo works fine – eli – 2017-01-13T11:56:58.797

This saved me some time and trouble. Thanks! – Brian Cowan – 2017-03-27T17:12:24.267

That looks like exactly what I was after, thanks! – Kromey – 2011-04-15T00:07:01.247

4

In Samba 4 and later, there's also samba-tool user list and other useful user management commands

McX

Posted 2011-04-14T22:31:27.780

Reputation: 149

2I believe this is only if you set up Samba to be an AD server. With a workgroup or NT4 domain Samba server, you need pdbedit -L as in the accepted answer. – mivk – 2019-01-09T12:54:12.893