Solved

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

Posted on 2014-12-04
5
265 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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é.
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now