How to Manage Samba users with pdbedit in Linux

The pdbedit program is used to manage the users accounts stored in the sam database in linux and can only be run by root.

1- To list all samba users.

[ root @ server1 ~ ]#  pdbedit   -L

user1:501

user2:502

user3:503

 

2-  List users with more detail.

[ root @ server1 ~ ]#   pdbedit   -L   -v

---------------

Unix username:        user1
NT username:          
Account Flags:        [U          ]
User SID:                  S-1-5-21-1611154369-1958735640-307523363-1000
Primary Group SID:    S-1-5-21-1611154369-1958735640-307523363-513
Full Name:            
Home Directory:       \\server1\user1
HomeDir Drive:        
Logon Script:         
Profile Path:         \\server1\user1\profile
Domain:               LEOLINUX
..........
 

 

3-   To list details for specific user.

[ root @ server1 ~ ]#   pdbedit  -L   -u  user1

user1:501

 

4-  To list in smbpasswd format.

[ root @ server1 ~ ]#   pdbedit  -L  -w

user1:501:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:B9D2D4955B330B503CC792EB6A55BB1F:[U          ]:LCT-5139B70A:

user2:502:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:B9D2D4955B330B503CC792EB6A55BB1A:[U          ]:LCT-5139B80N:
user3:503:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:B9D2D4955B330B503CC792EB6A55BB1B:[U          ]:LCT-5139B90B:

 

5- To delete user from samba database.

[ root @ server1 ~ ]#   pdbedit   -x  -u  user1   # -x option will delete user1 

[ root @ server1 ~ ]#   pdbedit    -L

user2:502

user3:503