Subscribe to How-To Geek

Recommended: Click Here to Run a Free Scan for Common PC Errors   [Sponsored Link]

Install Samba Server on Ubuntu

If you want to share files between your Ubuntu and Windows computers, your best option is to use Samba file sharing.

To install, first open a terminal window and enter the following command:

sudo apt-get install samba smbfs

We've got samba installed, but now we'll need to configure it to make it accessible. Run the following command to open the configuration file, substituting your editor of choice:

sudo gedit /etc/samba/smb.conf

Find this section in the file:

####### 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

Uncomment the security line, and add another line to make it look like this:

security = user
username map = /etc/samba/smbusers

This will set Samba to use the smbusers file for looking up the user list.

Create a Samba User

There are two steps to creating a user. First we'll run the smbpasswd utility to create a samba password for the user.

sudo smbpasswd -a <username>

Next, we'll add that username to the smbusers file.

sudo gedit /etc/samba/smbusers

Add in the following line, substituting the username with the one you want to give access to. The format is <ubuntuusername> = "<samba username>".  You can use a different samba user name to map to an ubuntu account, but that's not really necessary right now.

<username> = "<username>"

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

Share User Home Directories

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 01/7/07 and tagged with: Ubuntu, Adding Software

Comments (11)

  1. Ross

    Worked for me setting up a debian server on my slug. Thanks!

  2. Brian

    Great HOWTO. this worked perfectly. I was debating on using OpenFile but when I saw how easy this was, I chose this. Since Ubuntu is so stable and never needs to be restarted, I really think this was the right choice.

  3. The Geek

    I'm glad it worked for you guys! It took me quite a while to figure it out myself =)

  4. hhcv

    Hi,

    I had some problems with this guide. To fix, add the user before creating the password!

    Cheers.

  5. manolis

    The how-to is indeed very helpfull. I have still though a
    little problem. I can see either machine on the network but
    is seems that I am not permitted to access them. I am running
    Ubuntu Edgy (6.10) under VMWare on WinXP. Any ideas ?

  6. Lee

    Thanks, man! I had SAMBA installed and, for some reason, it just quit working. I uninstalled it and used your instructions and IT WORKS!

    Keep up the excellent work!

  7. Themba

    I just tried Samba Server on the network, It works great.

  8. Lee

    Why do I have to keep turning off the firewall on my Linux computer? Is there a way so it will work without doing that each time?

  9. hadge

    Hi, one problem for me - complete newbie - when I type the command - sudo smbpasswd -a - I get this error message - bash: syntax error near unexpected token `newline' - what's that about then?
    ;0)

  10. jimsg

    To reemphasize what hhcv said: I also needed to do
    sudo adduser SomeNewUserName

    (and give this new user a password)

    before I could successfully run

    sudo smbpasswd -a SomeNewUserName

    The first creates a UNIX user, the second creates an SMB user. I don't know if the two passwords need to be the same, but I made them the same just in case.

  11. Satish

    Hi man thx a lot now I slove the samba problem…..

    hey if you have the some trick for linux can you send me actualy I have exam for

    RHCE in spetember so I need hard study thx


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.