189

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.)

2 Answers 2

280

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.

2
  • Nope, doesn't work. I get tdbsam_open: Failed to open/create TDB passwd [/var/lib/samba/private/passdb.tdb] Apr 17, 2016 at 16:20
  • 8
    @starbeamrainbowlabs I get this error, too, when I run that command WITHOUT sudo! running it with sudo works fine
    – MacMartin
    Jan 13, 2017 at 11:56
17

In Samba 4 and later, if yours is an AD server, there's also samba-tool user list and other useful user management commands.

For Workgroup or NT4 domain Samba servers, pbdedit -L -v as above.

2
  • 9
    I 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
    Jan 9, 2019 at 12:54
  • 1
    samba-tool also doesn’t seem to be available from standard RHEL/CentOS RPM repositories: forums.centos.org/viewtopic.php?t=6368 Nov 9, 2021 at 22:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .