Avatar of Barry Kay
Barry KayFlag for South Africa

asked on 

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

We are running Linux openSUSE 12.2.
How do I get a list of SAMBA shares and their corresponding folders?
Linux

Avatar of undefined
Last Comment
Member_2_406981
Avatar of Manfred Bertl
Manfred Bertl
Flag of Germany image

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
      ---------            -------
ASKER CERTIFIED SOLUTION
Avatar of Member_2_406981
Member_2_406981

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Lelio Michele Lattari
Lelio Michele Lattari

testparm
Avatar of Barry Kay
Barry Kay
Flag of South Africa image

ASKER

/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.
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.
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo