Install and Configure Samba in Ubuntu

Overview

Samba is a file and print server that you can install on a Linux distribution like Ubuntu. It is useful for sharing files, folders, and printers with Windows users over a local network. In this lab, the goal is to install Samba in Linux, set up a shared folder and text file, and from a different computer running Windows workgroup, connect to the Samba share and access the shared folder and file. The lab is complete when you have open the shared file, added some text like “hello” and saved the file.

Installation and Configuration

To install Samba in Ubuntu, I followed the instructions on this website: https://help.ubuntu.com/10.04/serverguide/C/samba-fileserver.html

Open a terminal and put in the following commands (in the examples, “sudo” is used for root privileges):

  1. Update your repositories:
        sudo apt-get update
  2. Install with apt:
        sudo apt-get install samba
  3. Open the samba configuration file smb.conf. In this example I use the gedit text editor and I background the process with “&” so I can continue to use my terminal without having to close the text file first:
        sudo gedit /etc/samba/smb.conf &
  4. In the Global Settings section of the configuration file, change or verify the following lines:
    workgroup = WORKGROUP
    and in the Authentication section, change or verify the following lines:
    security = user
    I chose “WORKGROUP” because it is the default workgroup name in Windows.
  5. At the bottom on the configuration file add the following lines then save the file:
      [share]
    comment = Ubuntu File Server Share
    path = /srv/samba/share
    browsable = yes
    guest ok = yes
    read only = no
    create mask = 0755
    The path is the path to the shared folder, browsable allows the share to be visible to Windows explorer users, guest ok allows a user to access the share without supplying a password, create mask sets the permissions for everything created within the share.
  6. Now you need to create the directory folder to use as a share and change the owner and group:
        sudo mkdir -p /srv/samba/share
    sudo chown nobody.nogroup /srv/samba/share
  7. You can also create a sample text file in your shared folder to practice sharing to windows:
        sudo touch /srv/samba/share/test.txt
  8. Now restart samba:
        sudo restart smbd
        sudo restart nmbd (If you have nmbd failure, I found a temporary hack, see the bottom of this page)
  9. Now restart smbd and nmbd and it should work (after restarting if nmbd still does not work try restarting Ubuntu):
        sudo restart smbd
    sudo restart nmbd

  10. Now that you have Samba up and running go to another computer on your network that is running Windows and look for the share. Try the following steps and methods for locating your network share on Windows:
    1. open a folder (File Explorer) and type the IP address of the Samba server computer in the address bar (e.g.: \\192.168.1.100) and hit enter. If you are asked for a username and password, skip ahead to number 5.
    2. or, go to the Network and Sharing Center
    3. on the left hand side of the window click on “View computers and devices”
    4. if you are prompted by a drop down box, turn on “Network Discovery and File Sharing” for all public networks
    5. I had to put in my username and password like this:
      <username>@<computer-name>
      In my case it was:
      dan@dan-VirtualBox
      If you are unsure, open a terminal in you Linux machine and the prompt will be your user name + @ + your computer name.
    6. once authenticated you should have access to the file shares and shared printers that you created and configured in Samba.
    In this image, you can see the “Network and Sharing Center” window, the “View Computers and devices”
    window, as well as my Samba share “DAN-VIRTUALBOX”, and a window with a shared text file


Video Tutorial

 


***Troubleshooting note:

  1. If you notice that nmbd is failing… This bug seems to be a recent occurrence in Ubuntu 10. Here is a temporary hack that I found on a separate website blog. Open the nmbd.conf file in gedit:
        sudo gedit /etc/init/nmbd.conf &
    Comment out the following lines in the nmbd.conf file by adding a “#” at the beginning of the line like this:
        #          NMBD_DISABLED=`testparm -s –paramenter-name=’disable netbios’  2>/dev/null`
    #          [   “x$NMBD_DISABLED” = xYes  ]  &&  {  stop; exit 0;  }