Looking for a simple way to do this from the command line.

List samba shares and the users who can access each of them.

List samba shares and the users currently connected to them.

List samba shares and every connection (log, including user) that has been established to each of them.

Any ideas? Anything you use that's currently available that will give me the bits I need to put this together?


  • 2
    We can list shares from command line using smbtree. We can parse: /etc/samba/smb.conf /var/lib/samba/usershares/*.conf
    – komputes
    Feb 14, 2012 at 18:45

9 Answers 9


Try smbclient -L ip_of_net_interface -U your_user_name. This option allows you to look at what services are available on a server. You use it as smbclient -L host and a list should appear.

  • 1
    Yeah, a very complete listing: shares, servers, workgroup. Thanks! Jan 30, 2021 at 17:10
  • 1
    smbclient: command not found Jan 24, 2023 at 13:06
  • Please google for how to install the smbclient on the distribution you use @Friedrich--СлаваУкраїні
    – guenhter
    Jan 24, 2023 at 13:26
  • 1
    @guenhter: Even easier, I used smbstatus; it didn't need an install. Jan 24, 2023 at 13:31
  • conveniently, you can use it against your own server's IP address to see what shares you are hosting if you forgot Feb 15 at 19:47

Try to use smbstatus, it seems to be what you need.

  • 22
    smbstatus only lists the current connections. What about listing all shares and users who can access them (even if not connected at the time)?
    – labyrinth
    Apr 15, 2015 at 16:16
  • 6
    A little more details would have been appreciated
    – frepie
    Sep 10, 2017 at 20:29
smbstatus --shares

Will retrieve what's being shared and which machine (if any) is connected to what.

  • 3
    Perfect! But it only shows if im browsing the share, but not if I just have it mapped to Windows. Where NFS shows constantly, but I guess thats because NFS is constantly "mounted", Windows is just mapped, and not mounted till accessed. Dec 15, 2016 at 17:47

Try net usershare info --long.

/usr/bin/net -> /etc/alternatives/net
/etc/alternatives/net -> /usr/bin/net.samba3

$ man net
net - Tool for administration of Samba and remote CIFS servers.
  • Best answer -- it's been a very long time since I worked with samba and didn't know about the net command
    – nitrogen
    Feb 16, 2020 at 22:26
  • or, to show shares that are not usershares, net share list --long Oct 26, 2023 at 18:25

Also, on most systems, typing testparm will give you info about the samba shares of the machine you're currently using. After you press enter at the prompt it'll also show you every uncommented line of smb.conf which can be useful.

  • 2
    No, testparm only checks for correctness of the configuration file, it shows nothing about what you are currently using.
    – ChristophS
    Mar 10, 2020 at 9:32

Use the command pdbedit.

sudo pdbedit -L -v

Where -L is to list users & -v is to be verbose.


Getting the users

net rpc user

Getting the shares per user

Less verbose than smbclient -L is net rpc share list -U $USERNAME

You'll need both because the list of visible shares differs per user.


While smbstatus --shares list active connections in your computer, you may want to know which folders are selected as samba shared, even when no current connection is active.

Go into this directory and you will get the name of such folders:

cd /var/lib/samba/usershares

I am sharing the list of command that everyone need if you are using smb, I hope this will help you all. if need any help for the same, please comment, I will try to help you to have solution for your problems.

you can write sudo smbstatus command to see the logs shared folder and status of that as well

Samba version 4.7.6-Ubuntu
PID     Username     Group        Machine                                   Protocol Version  Encryption           Signing              

you can write the command sudo smbtree to get the tree of root folder and subfolders

\\SSHEEL-HP             ssheel-HP server (Samba, Ubuntu)
    \\SSHEEL-HP\IPC$            IPC Service (ssheel-HP server (Samba, Ubuntu))
    \\SSHEEL-HP\sambashare      Network Shared Folder by Samba Server on Ubuntu
    \\SSHEEL-HP\print$          Printer Drivers

you can also type sudo smbcontrol command to get all list of controls that you can use with suffix of that command

if you are getting problem to login so you can also set password for smb to get access of shared folders sudo smbpasswd -a ssheel

ssheel@ssheel-HP:~/Videos$ sudo smbpasswd -a ssheel
New SMB password:
Retype new SMB password:
Added user ssheel.

You must log in to answer this question.

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