Is there possible to list all shared folders (with their physical locations) from command line?
7 Answers
go to list folder
/var/lib/samba/usershares
check the path
-
Under this path (
/var/lib/samba/usershares
) only some of my shared folders are available. In other machine there is other folders shown under my machine such as: My Printers,print$
andIPC$
which are not listed in the pass in your answer! Aug 2, 2015 at 12:07
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
-
I get this error:
Connection to localhost failed (Error NT_STATUS_CONNECTION_REFUSED)
– LokeshNov 3, 2016 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. Nov 17, 2016 at 15:44
-
@Lokesh I think Tobias' coment was meant to be addressed to you. I'd also mention that this specific error usually means that nobody is listening on 139 and 445 port (samba should be listening on at least one of them). You can check if it's true with
ss -an | grep -P "\b(139|445)\b"
.– Hi-AngelApr 15, 2021 at 13:58
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://[email protected]/
Type: GDaemonMount
Mount(2): WebDAV as bert on server.example.com -> davs://[email protected]/dav
Type: GDaemonMount
If you add the option -i
you get even more information.
-
Worth mentioning, the command is deprecated in preference of
gio mount -l
– Hi-AngelApr 15, 2021 at 14:18
For samba shares we have a set of utilities that come with the 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
-
-
2
-
This is the result for
sudo smbstatus --shares
:Service pid machine Connected at
(nothing in the list). Aug 2, 2015 at 17:01
If you browse your own machine in the Network section of Nautilus, you should see all the shares.
-
In Nautilus, the is a "Browse Netwrok" Item in the sidebar. Inside it, there is only one item: "Windows Network" and inside it there is only one item: "WORKGROUP". If I double click WORKGROUP it asks me for user name and password and if I enter my user name and password for my Ubuntu, it does not accept it! Can you help? Aug 2, 2015 at 12:04
Hit Alt+Ctrl+T to open terminal and run the following command:
smbtree
-
1I tested this command, but it only shows:
WORKGROUP \\ host-name server (Samba, Ubuntu)
Aug 2, 2015 at 12:08
At least two ways to do this:
1. mount
$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=1959288k,nr_inodes=489822,mode=755)
...
# etc, etc
With no options, mount
will list all mounted file systems. Two options are available:
-l
: includes labels-t <type> : filters the output by filesystem <type>; e.g.
cifs`
See man mount
for details. An example from my system:
$ mount -l -t cifs
//NetgearNAS-3/backup on /mnt/NetgearNAS/backup type cifs (rw,relatime,vers=1.0,cache=strict,username=seamus,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.246,soft,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=65536,bsize=1048576,echo_interval=60,actimeo=1)
//SynologyNAS-1/backups on /mnt/SynologyNAS/backups type cifs (rw,relatime,vers=3.1.1,cache=strict,username=seamus,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.102,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,user=seamus)
2. findmnt
From man findmnt
:
findmnt will list all mounted filesystems or search for a filesystem. The findmnt command is able to search in /etc/fstab, /etc/mtab or /proc/self/mountinfo. If device or mountpoint is not given, all filesystems are shown.
With no options, findmnt
provides a neat listing of all mounted filesystems in tree format:
$ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,relatime,errors=remount-ro
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,mode=755
...
# etc, etc
findmnt
has an extensive set of filtering and formatting options, making it well-suited for use in scripts where the output must be parsed - see man findmnt
for details. In this case, if we wish to restrict the output to shares (as in the smb/cifs/nfs sense), the -t
option is handy:
$ findmnt -t cifs,nfs4
TARGET SOURCE FSTYPE OPTIONS
/mnt/SynologyNAS/rpi_share SynologyNAS-1:/volume1/rpi_share nfs4 rw,relatime,vers=4.1,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,se
/mnt/NetgearNAS-3/backup //NetgearNAS-3/backup cifs rw,relatime,vers=1.0,cache=strict,username=seamus,uid=0,noforceuid,gid=0,noforcegid,addr=192.16
/mnt/SynologyNAS/backups //SynologyNAS-1/backups cifs rw,relatime,vers=3.1.1,cache=strict,username=seamus,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.
-
@andrew.46: That's fine... I agree that closing the other question was the right thing to do. Just so you know, my thinking was, "Well, if they allow duplicate questions here, why not duplicate answers?"– SeamusJul 14, 2022 at 6:19