8

Is there possible to list all shared folders (with their physical locations) from command line?

| improve this question | | | | |
  • 2
    Sharing using the same OS? Are using Samba? – Mitch Oct 10 '12 at 9:53
  • both, if possible – ts01 Oct 10 '12 at 10:17
  • to also find the respective local paths, see all answers here – phil294 Dec 7 '19 at 17:25
5

For samba shares we have a set of utilities that come with the samba Install samba suite:

  • smbtree

    smbtree is a smb browser program in text mode. It is similar to the "Network Neighborhood" found on Windows computers. It prints a tree with all the known domains, the servers in those domains and the shares on the servers. Manpage

  • smbstatus

    smbstatus is a very simple program to list the current Samba connections. Manpage

    By invoking the following a list of shares will be displayed:

    smbstatus --shares
    

See also: Manpage of samba

| improve this answer | | | | |
  • Non of smbtree and smbstatus commands list my shared folders! – PHP Learner Aug 2 '15 at 12:18
  • @PHPLearner: try with sudo smbstatus --shares – Takkat Aug 2 '15 at 14:47
  • This is the result for sudo smbstatus --shares: Service pid machine Connected at (nothing in the list). – PHP Learner Aug 2 '15 at 17:01
3
gvfs-mount -l

GVFS is the virtual filesystem for the Gnome desktop that allows access to shared drives via SMB, FTP, WebDav, and SFTP. Accessed shares are mounted under ~/.gvfs/, you can see them there as well.

The command above lists all attached external drives, and network shares, e.g.:

$ gvfs-mount -l
Drive(0): 1.5 TB Hard Disk
[snip]
Mount(0): public on fileserver -> smb://fileserver/public/
  Type: GDaemonMount
Mount(1): SFTP for bert on server.example.com -> sftp://bert@server.example.com/
  Type: GDaemonMount
Mount(2): WebDAV as bert on server.example.com -> davs://bert@server.example.com/dav
  Type: GDaemonMount

If you add the option -i you get even more information.

| improve this answer | | | | |
3

Use this command: smbclient -L localhost. A sample of its output is as follow:

Enter username's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.6-Ubuntu]

Sharename       Type      Comment
---------       ----      -------
print$          Disk      Printer Drivers
IPC$            IPC       IPC Service (host-name server (Samba, Ubuntu))
hp1320          Printer   Hewlett-Packard hp LaserJet 1320 series
HP-LaserJet-1200 Printer   HP LaserJet 1200
Public          Disk      
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.6-Ubuntu]

Server               Comment
---------            -------
                     host-name server (Samba, Ubuntu)

Workgroup            Master
---------            -------
WORKGROUP            HOST-NAME
| improve this answer | | | | |
  • I get this error: Connection to localhost failed (Error NT_STATUS_CONNECTION_REFUSED) – Lokesh Nov 3 '16 at 12:30
  • Are you trying this on the machine that has the share setup? Else change it to the IP address of the server you are trying to read. – Tobias Hagenbeek Nov 17 '16 at 15:44

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.