File sharing using SMB on Linux Mint

A quick how-to on file sharing using SMB on Linux Mint

A friend of mine was having trouble setting up file sharing between his two Linux workstations. So I decided to give it a go myself and do a quick how-to guide.

He runs Mint on one of his machines and PinguyOS on the other. Both machines are configured to dual-boot Linux and Windows.

I created a Linux Mint VM (17 "Qiana", Cinnamon, 64-bit) on VMware ESXi (1 GB RAM, 1 vCPU, 16 GB Thin Provisioned disk, PCSCSI, vmxnet3 adapter). Very straight-forward install, basically selected all the defaults. Disk encryption was not enabled. Gave it the hostname 'castor' and enabled DHCP. It picked up the IP address Created an account called 'harish' during the install.

Once it was up and running, I installed VMware Tools, and updated the system.

Sharing a folder

Created a folder called 'shared' on the desktop. Then right click, select 'Sharing Options'.

Gave it a share name, added a commment, and selected 'Allow others to create and delete files in this folder'.

Because I had selected the 'Allow others...' option, upon hitting the 'Create Share' button, I got another prompt telling me that Nemo needed to add some permissions to the folder to allow write permission by others.

I selected 'Add the permissions automatically' and it did its thing.

At this point, from a Windows machine, I tried pinging the Linux machine using its name 'castor'. It was able to resolve it.

On the Windows machine, from a run prompt, I typed "\castor\shared" and hit enter.

On the security dialog, I tried entering my credentials (the username and password of the Linux account on Mint).

It didn't work. I then remembered that I had to create an SMB account on the Linux machine.

The -a option tells it to add the new user to the local smbpasswd file and prompt for a new password.

Tried again, and this time, it worked.

Created a new file in that folder from the Windows machine to confirm that I had 'write' access.

Mounting the share on a Linux machine

This was really simple. On one of my other machines (Ubuntu Server 14.04 LTS, hostname 'bellatrix'), I mounted the SMB share.

harish@bellatrix:~$ sudo apt-get update  
harish@bellatrix:~$ sudo apt-get upgrade  
harish@bellatrix:~$ sudo apt-get install cifs-utils  
harish@bellatrix:~$ cd /mnt  
harish@bellatrix:/mnt$ sudo mkdir mint  
harish@bellatrix:/mnt$ smbclient -L  
Enter harish's password:  
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.6-Ubuntu]

        Sharename       Type      Comment
        ---------       ----      -------
        IPC$            IPC       IPC Service (castor server (Samba, Linux Mint))
        print$          Disk      Printer Drivers
        shared          Disk      Shared folder on Mint
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.6-Ubuntu]

        Server               Comment
        ---------            -------
        CASTOR               castor server (Samba, Linux Mint)

        Workgroup            Master
        ---------            -------
        WORKGROUP            CALLISTO

harish@bellatrix:/mnt$ sudo mount -t cifs -o sec=ntlm,username=harish,password=Password1,rw // /mnt/mint/  
harish@bellatrix:/mnt/mint$ ls -al  
total 16  
drwxrwxrwx  2 harish harish     0 Jun 22 17:01 .  
drwxr-xr-x  6 root   root    4096 Jun 22 17:04 ..  
-rw-r--r--  1 harish harish     0 Jun 22 16:59 TestFile1
-rw-r--r--  1 harish harish     0 Jun 22 16:59 TestFile2
-rwxrwxr--+ 1 harish harish 11284 Jun 22 17:01 Test Word Doc.docx

In the 'mount' command, the username and password you provide must match the username and password of the account you added to smbpasswd.

That was it!