humpty promotes - Linux - Lubuntu

Lubuntu linux Tips
Setting up SAMBA (SMB file sharing)

How to access SMB shares using GVFS
How to setup a SAMBA share
How to access SMB shares without GVFS

One of the most useful things you might like to do after installing Lubuntu is to share files between PCs.

SMB has been the choice for most users because you can share files between linux,windows and most other OSs including Android on mobile phones.

Traditionally Linux uses SAMBA to do this but If you only want to 'get' files from another smb source, installing CIFS alone is enough.

Even with CIFS, accessing a share involves having to set up 'mounts', But, there is an easier way by installing a system called 'gvfs' which allows a 'gio' enabled app to access samba shares with a simple URI string e.g smb://hostname/shared_dir

The gvfs/gio system has matured for a good many years now and is pretty fast and reliable. No more messing about with scripts and config files or wondering why smb performance is so slow.

How to access SMB shares using GVFS
using Synaptic, install


Open PCmanFM and enter       smb://        on the address line.

If you have any smb shares on you network, then you should see something like 'WORKGROUP' in the file manager and you can click into it to access the shares.

In the past you had to install CIFS and write some scripts to mount the shares, but gvfs/gio transparently integrates the shares to a requested URI (smb://hostname/shared_dir).

How to setup a SAMBA share
using Synaptic, install


From LxPanel menu, open System Tools>Samba
Here you can easily create a share of your choice directory, which you can access using the gvfs setup (above).

In the past, you had to go through the horrible process of writing config files and scripts for mounting. But this gui combined with the gvfs setup does it all for you.

How to access SMB shares without GVFS

The problem with gvfs (apart from installing a bloatload of other stuff) is that your apps needs to be 'gio' enabled, that is they must be designed to access gvfs type URIs.
Gvfs does infact also create a hidden directory ~/.gvfs containing (fuse)mounts for non-gio apps. But they only exist if the smb share is actually accessed for the first time, which is like a chicken-egg situation.

Gvfs provides a way to look up smb shares without first knowing the IP of the host. But there is another way (without installing gvfs) of knowing the IP if you already know the hostname.

There is a utility called nmblookup that maps netbios names to IP addresses, (in Lubuntu it is part of the package samba-common-bin and is part of the samba suite).

nmblookup <hostname of your other PC>
>nmblookup myhost
querying myhost on myhost<00>

with some ingenuity, you can filter out the output to leave just the IP address (below).

Setup your share as above ('how to setup a samba share') on your other PC. Then try the scripts below;

Script to mount a Share

Automatically mount a share knowing host=myhost, sharename=myshare, and user=myuser;
to a directory on /mnt/myshare;

sudo mkdir /mnt/myshare 2>/dev/null
sudo umount /mnt/myshare 2>/dev/null

IPADR=$(nmblookup -R myhost | grep 'myhost<00>' | cut -d' ' -f1)

sudo mount --type cifs -o
guest,uid=myuser,gid=myuser //$IPADR/myshare /mnt/myshare

echo myhost/myshare $IPADR on /mnt

Script to mount a Share on Android phone host to your PC /mnt/myshare

Automatically mount a share on a phone knowing host=phone_host, password=a_pass,
sharename=my_share, and user=myuser; to a directory on /mnt/myshare;

sudo mkdir /mnt/myshare 2>/dev/null
sudo umount /mnt/myshare 2>/dev/null

IPADR=$(nmblookup -R phone_host | grep 'phone_host<00>' | cut -d' ' -f1)
--type cifs -o noperm,rw,user=myuser,password=a_pass,sec=ntlm,uid=myuser,gid=root'
sudo mount  $OPTS //$IPADR/sdcard /mnt/$myshare

echo myhost/myshare $IPADR on /mnt/myshare

For this to work , you need only install
samba (includes samba-common, samba-bcommon-bin)

It might be a little work to setup at first, but it is much more reliable than gvfs because there are still a lot of apps that don't work well with gvfs URIs.


In a SMB share network, certain ports have to be open if you are using a firewall. These are for PCs to request share names and communication. The ports are 135,139,445 tcp and 137,138 udp and need to be let through in both directions.

(GVFS also works for other resources e.g ftp://, afp, afc, cdda .. and a bloatload of other stuff you never use..)

The default filemanager PCmanFM is already enabled with gio, but apps that don't accept these URIs can still access the shares through a hidden fuse mounted directory in ~/.gvfs/
In order to access this directory you must be added to the group 'fuse';  usermod -a -G fuse <username>

[ home ]

Leading Cloud Surveillance, Recording and Storage service; IP camera live viewing

Leading Enterprise Cloud IT Service; cloud file server, FTP Hosting, Online Storage, Backup and Sharing

Powered by, a division of DriveHQ, the leading Cloud IT and Cloud Surveillance Service provider since 2003.