Is there a practical way, e.g. net command or other cli to get a list of all shares defined on a Linux server (Ubuntu distribution) listing not only the share name but also the full path to the local shared directory? Without having to look at samba config files or user shares files.


No, you cant

smbclient -L 

Shows the shares, but you have to look this up in your smb.conf to find the path.

  • Do you have to specifiy an IP or name here, like smbclient -L localhost ? At least for other machines one can say smbclient -L -U ourdomain\\myUsrName – eli Mar 13 '18 at 6:32

Yes, you can.

The solution (found thanks to http://ubuntuforums.org/showthread.php?t=1304277&p=8186452#post8186452) is to look at the directory /var/lib/samba/usershares : it contains one file per share, and each file has a line starting with path= containing the local path


Try this script ... feel free to improve it

while read line; do
    [[ "$line" =~ ^\[ ]] && name="$line"
    [[ "$line" =~ ^[[:space:]]*path ]] && echo -e "$name\t$line"
done </etc/samba/smb.conf
  • Nice one, I'll try it. Meanwhile I guess it will miss usershares – a1an May 31 '12 at 12:12
  • Confirmed to miss usershares, I've improved on your script to include them – a1an Jun 18 '12 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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