Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

803 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