Little Girl's Mostly Linux Blog

Samba

Samba

This page was last updated on July 18, 2009.

Since I get a lot of requests from people who would like a page on how to set up and use Samba in Ubuntu, here it is. The information here worked successfully for people a couple of years ago, and unless the method has changed, it should still work. I have no way of testing it since I don’t have Windows on any of the computers here. My email is in the menu bar at the top of the page if I’m horribly wrong and you want to set me straight. (:

Install Samba

Open a terminal window and type this command to install Samba and smbfs:
sudo apt-get install samba smbfs

Configure Samba

  1. Type this command in a terminal window to open the Samba configuration file:
  2. gksudo gedit /etc/samba/smb.conf
  3. Find this section in the file:
  4. ####### Authentication #######
    
    # "security = user" is always a good idea. This will require a Unix account
    # in this server for every user accessing the server. See
    # /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
    # in the samba-doc package for details.
    ;  security = user
    
  5. Uncomment the security line by removing the semi-colon and the space.
  6. Add this line beneath the now uncommented security line:
  7. username map = /etc/samba/smbusers
  8. Your changes should match this example:
  9. ####### Authentication #######
    
    # "security = user" is always a good idea. This will require a Unix account
    # in this server for every user accessing the server. See
    # /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
    # in the samba-doc package for details.
    security = user
    username map = /etc/samba/smbusers
    
  10. Save and close the file.

Create a Samba user

  1. Type this command in a terminal window to assign a Samba password to the user:
  2. sudo smbpasswd -a USERNAME

    Note: Replace USERNAME with your Ubuntu username.

  3. It will ask for your Ubuntu password.
  4. Enter your Ubuntu password.
  5. It will then ask for a new password.
  6. Enter the password you’d like to use for Samba.

Add the user to Samba

  1. Type this command to edit the Samba users file:
  2. gksudo gedit /etc/samba/smbusers
  3. Add the following line to the file, replacing UBUNTU_USERNAME with your Ubuntu username and WINDOWS_USERNAME with the Windows username who will be accessing the Ubuntu machine.
  4. UBUNTU_USERNAME = WINDOWS_USERNAME

    Now you can create samba shares and give access to the users that you listed here.

Share your Ubuntu home directory

  1. To share your Ubuntu home directory and make it so the Windows user has the power to write to the Ubuntu drive, type this command in a terminal window to configure Samba:
  2. gksudo gedit /etc/samba/smb.conf
  3. Find this section of the file, and make it match the following:
  4. #======================= Share Definitions =======================
    
    # Un-comment the following (and tweak the other settings below to suit)
    # to enable the default home directory shares. This will share each
    # user's home directory as \\server\username
    [homes]
    comment = Home Directories
    browseable = yes
    
    # By default, \\server\username shares can be connected to by anyone
    # with access to the samba server. Un-comment the following parameter
    # to make sure that only "username" can connect to \\server\username
    valid users = %S
    
    # By default, the home directories are exported read-only. Change next
    # parameter to 'yes' if you want to be able to write to them.
    writable = yes
    

Restart Samba

Type this command in a terminal window to restart Samba to use the new configuration:
sudo /etc/init.d/smb restart

Set up the Samba share in Windows

When mapping a drive in Windows to access the share, use the following format:
\\UBUNTU_COMPUTER_NAME\UBUNTU_USERNAME
For example, if your Ubuntu computer’s name is MyUbuntuComputer and your Ubuntu username is LittleOldMe, then you would use this information to map the Windows drive:
\\MyUbuntuComputer\LittleOldMe

Connect to the Samba share in Windows

When Windows asks to connect to the Ubuntu share, enter your Ubuntu username and your Samba password to connect.


Obligatory Happy Ending

And they all lived happily ever after. The end.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: