Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Linux: How do I get a list of SAMBA shares and their corresponding folders?

Posted on 2014-12-04
5
281 Views
Last Modified: 2014-12-08
We are running Linux openSUSE 12.2.
How do I get a list of SAMBA shares and their corresponding folders?
0
Comment
Question by:bax2000
5 Comments
 
LVL 4

Expert Comment

by:mbertl
ID: 40480255
You can get that with: smbclient -L <host> -U <user> and then you get asked for the password. Enter the password for that given username and you get a list like this:

[11:28:02][s1gny@opteron.local]
[/home/s1gny]$ smbclient -L localhost
Enter s1gny's password:
Domain=[SUPERNET] OS=[Unix] Server=[Samba 4.1.1]

      Sharename       Type      Comment
      ---------       ----      -------
      camera-archiv   Disk      
      scan            Disk      
      tmp             Disk      
      raid5           Disk      
      daten           Disk      
      root directory  Disk      
      iX-6850         Printer   Samsung CLX-6220 Series (samsung)
      Stylus-Photo-R320 Printer   EPSON Stylus Photo R320
      clx6220         Printer   clx6220
      IPC$            IPC       IPC Service (Opteron (4.1.1))
      s1gny           Disk      Home Directories
Domain=[SUPERNET] OS=[Unix] Server=[Samba 4.1.1]

      Server               Comment
      ---------            -------

      Workgroup            Master
      ---------            -------
0
 
LVL 11

Accepted Solution

by:
andreas earned 500 total points
ID: 40480401
The folders to the respective shares can be found in the samba configuration which can be found in

/etc/samba/smb.conf

each share has a section [sharename] and in this section there is an option
path = where you can see which path on the filesystem the share is shareing.

over the smb-protocol there is no way to find this out.
0
 

Expert Comment

by:Lelio Michele Lattari
ID: 40480424
testparm
0
 

Author Comment

by:bax2000
ID: 40486284
/etc/samba/smb.conf   works well but how can I pipe it to a file and keep the same neat formatting?
If I use >  to pipe to a text file it does not keep the format.
0
 
LVL 11

Expert Comment

by:andreas
ID: 40486322
try

cat smb.conf |grep -v -e global -e logon -e homes | grep -e '\[' -e 'path' >~/out.txt

Open in new window


this will put only the share names in [] and the corresponging paths in the output file. the rest will be cut away.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question