Basic Samba Setup On Ubuntu 10.04 Lucid Lynx



Ubuntu 10.04 Lucid Lynx has come out, and that means it’s time to explain how to do a basic Samba setup on the new version. All Terminal commands in this walkthrough are bolded, and USERNAME stands for your username on your Ubuntu system.

First, you’ll need to install Samba. Fire up a Terminal window and use this command:

sudo apt-get install samba

Follow the default prompts to install Samba. Now, Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you’ll need to create a Samba password for yourself with this command:

sudo smbpasswd -a USERNAME

(USERNAME, of course, is your actual username.)

Type a suitably strong password (make sure it includes uppercase, lowercase, punctuation, and numbers). Once your password is created, the next step is to edit your /etc/samba/smb.conf file, the configuration file for Samba. Begin by creating a folder named ‘test’ on your home folder; we’ll use that for our test shared folder (you can create other shared folders using the same method):

mkdir /home/USERNAME/test

Next, make a safe backup copy of the original smb.conf file to your home folder, in case you make an error:

sudo cp /etc/samba/smb.conf ~

Now use your text editor of choice to edit smb.conf:

sudo gedit /etc/samba/smb.conf

(New users will probably find gedit the easiest to use due to its GUI; but you can use emacs or vi just as readily, especially if you’re using the server version of Ubuntu, which doesn’t include X11 by default.)

Once smb.conf has loaded, add this to the very end of the file:

[test]
path = /home/USERNAME/test
available = yes
valid users = USERNAME
read only = no
browsable = yes
public = yes
writable = yes

(There should be no spaces between the lines, and note also that there should be a single space both before and after each of the equal signs.)

These settings will share the test folder we created earlier, and give your username and your username alone permission to read and write to the folder. Once you have input the changes, save smb.conf, exit the text editor, and restart Samba with this command:

sudo restart smbd

Once Samba has restarted, use this command to check your smb.conf for any syntax errors:

sudo testparm

If you pass the testparm command, Samba should be working; try accessing the shared folder from another computer on your LAN.

-JM

ADDITIONAL READING:

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide.

This entry was posted in Linux. Bookmark the permalink.

40 Responses to Basic Samba Setup On Ubuntu 10.04 Lucid Lynx

  1. Eric says:

    Thanks so much for this! I’m going to post it on the Ubuntu forums. There are so many older threads about this that either don’t work anymore or are way more complicated.

    I wish I had this guide the first time I got Samba working…it was a nightmare!

  2. Jonathan, you have no idea how thankful I am right now. I’ve spent a weekend trying to get Samba working on my freshly installed Ubuntu Lucid. I felt so lost, but then I found your article. The “smbpasswd” part did the trick. Thanks!

  3. Luca says:

    I followed the tutorial but it’s not working for me.
    I want to access the shared folders on my “Lucid” PC from my Xbox. It used to work until I upgraded to Lucid Lynx…
    Now it asks for username/pwd but even though I input the right combo, it won’t let me access the shared folders.

    here’s my smb.conf:

    [SHARES]
    path = /home/luca/Shares
    comment = /home/luca/Shares
    available = yes
    valid users = luca, xbox
    read only = no
    writable = yes
    browseable = yes
    public = yes

    Any help? Please!!

  4. BEREGU says:

    It didn’t follow this tutorial, but I installed samba from synaptic software manager. Then I used Samba GUI tool. Everything except uploading files from local computers working very good.

    I could only upload a file less than 40KB in a time. hehehe….. Funny?

  5. Ian says:

    This totally didn’t work for me. Glad to know the new samba start command, but I don’t understand why it was changed. Lucid broke my LAN TV by changing samba.

    sudo testparm is happy with my smb.conf, but my Karmic media machine gets its passwords rejected and my Geexbox can’t see hard drives mounted to the Lucid server by USB.

  6. David says:

    Hi, Thanks for the above — very helpful. My solution, inspired by your VERY helpful lead, was even more simple.

    I did an upgrade from 9.10 to 10.04 and lost my inbound shares from my Windows network. Ubuntu could see Windows, but Windows machines could not see Ubuntu box [where my music is stored =:-0])

    I got working again like this:

    At the Terminal window:

    sudo apt-get install samba

    Follow the default prompts to install Samba.
    My upgraded system already had Samba installed (I think – anyway, it reported nothing added and nothing deleted)

    “Now, Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you’ll need to create a Samba password for yourself with this command:”

    sudo smbpasswd -a USERNAME

    It will respond and ask you to set up a password.

    I then simply started Samba

    sudo start smbd

    …and I was able to use the use the folder shares controls.

    WTF! I really cannot understand how a Release version can get out which breaks network shares. The ‘offical’ bug support forums provide no guidance. And then people wonder why Linux/Ubuntu is not adopted by mainstream users.

  7. Live says:

    Thanks it worked!

    1. I have 1 Ubuntu Lucid file server and 2 Windows machines.

    -in my Ubuntu (edit smb.conf – put this at the bottom):

    [home_file_server]
    path = /home/bart/home_file_server/
    public = yes
    available = yes
    read only = no
    valid users = @family
    browsable = yes
    writable = yes

    ***THAT’S IT, I DIDN’T TOUCH ANY OTHER CONFIG IN My Default SMB.CONF!!!***

    2. Windows – Map Network Drive – ok! – BUT keeps asking for password.

    3. Your blog’s MAGIC COMMAND:

    sudo smbpasswd -a USERNAME

    Note: this will fail if the USERNAME IS NOT YET in the Ubuntu File Server Machine (host), so add your users first!

    Why? Like you said above: “…Now, Samba uses a separate set of passwords than the standard Linux system accounts”

    4. to delete users:

    sudo smbpasswd -x USERNAME

    5. man smbpasswd to get more info.

    God bless you man, I’ve been working for 1 week to get this thing running. :)

  8. Me says:

    I hope you will receive this as constructive but it’s causing people to do funny things on the Ubuntu forums.

    You might want to change the title to something like: “Basic Authenticated Share Setup on Ubuntu”
    Because you’ve created a share that is accessible only by the owner of the share. It requires the client user to access the share with the owners username ( and most likely his login password as well ). It’s also being interpreted more broadly to mean that for any type of samba to work the share owner must create a samba password for himself when that should never be done.

    I understand why you did it the way you did:
    /home/USERNAME/test is going to have permissions of 0755 so adding the only valid user that has write access to the share eliminates the need to do a chmod. You could have used nautilu-share ( Nautilus > right click on /home/USERNAME/test > Sharing options ) which would have automatically modified the permissions to allow guest access.

  9. Jonathan Moeller says:

    Me:

    “You might want to change the title to something like: “Basic Authenticated Share Setup on Ubuntu”
    Because you’ve created a share that is accessible only by the owner of the share.”

    Well, that WAS the point of the post. But I see your point, and will change to title to reflect that.

  10. Pingback: Samba file sharing in Ubuntu Lucid 10.04 LTS « Reformed Musings

  11. Daniel says:

    Great, thanks! For some reason I could not get my shared folders to become accessible on other computers via Nautlius-sharing. After following these steps in your tutorial it works just fine!

  12. Jedi Penguin says:

    Very helpful, I’m at least making some progress with your instructions.

    Now that I’ve set a password, and able to access that share as the user who created it, can I just set up other shares which will NOT require authentication, so everyone on the network can access files in them without having to authenticate? I’m trying that, but without much success. Can I remove the password for Samba, or am I not understanding the process correctly?

  13. Dave says:

    bump

    Comment from Jedi Penguin
    Time May 25, 2010 at 7:46 pm

    Very helpful, I’m at least making some progress with your instructions.

    Now that I’ve set a password, and able to access that share as the user who created it, can I just set up other shares which will NOT require authentication, so everyone on the network can access files in them without having to authenticate? I’m trying that, but without much success. Can I remove the password for Samba, or am I not understanding the process correctly?

  14. jester says:

    twas an easy guide to follow. thanks! i know that i may bump into little errors here and there but i believe i can handle it. thanks again!

  15. Antonio says:

    Thank you very much. I put into communication Lucid Lynx with Windows 7 machine and it worked for me at first attempt. Only little change for the command to restart samba. On my PC it is

    sudo service smbd restart

    Thank you again

    antonio

  16. Doug Coulter says:

    This does NOT work for folders shared under other than /home/user at all. The new smb.conf is seriously broken — older versions on older ubuntus work fine and I can share anything. On this version, even a subfolder under /home/me/Public can’t be copied to another machine — it can’t seem to give me anything but “file not found” even though the folder does show up as shared.

    For things other than /home/user they don’t show up on the network at all….and only Lucid with its new comment-free smb.conf has this problem.

    20+ hours into this as an experienced sysadmin — tempting to revert opsys at this point. That file is so hard to “diff” with one that works, I may just try overwriting it (after making a backup) with one that works elsewhere…..

    Note, this is mainly with a fresh install of lucid — upgrading from an earlier ubuntu where all this works, it stays working, mostly…
    All my 7.x and 8.x and 9.x machines share fine, this is a new bug from them. The immediate fix is to use them as way points, and copy to them from here, then get things from them over there — what a pain!

  17. Cory Neitz says:

    works like a charm. who woulda thunk ya wouldnt have to change any default smb.conf settings, aside fromt he shares. all of mine are in the /media directory Doug. And all are accessible by whom I’ve told smb.conf to via the valid users, of which i need to create an ubuntu system username/pw and then a seperate smbpasswd. works great! love it!

  18. mmk says:

    Tx, I am a newbie and managed to setup a file share using samba. Now trying to setup a domain controller.

  19. Simon says:

    You can use this with other users on your home network – just make sure to create the user on your ubuntu box first. System > Administration > Users and Groups.

    I created a second user on the machine and then placed the folder I wished to share in their home folder. I did change the permissions on their home folder using

    chown -R userX:admin userX

    I also chmodded the directory to chmod -r 775 userx so as a member of admin I could get into their directory if needed.

    Then I simply followed the directions set out by Johnathan above and it all works swimmingly.

    I haven’t tried to do this next bit but you could probably share the same folder with several users just based on their actually being setup on the ubuntu system first and then setting the correct permissions on the folder you wish to share.

    Thanks much Johnathan, you’re simple instructions were exactly what I was looking for.

    Simon

  20. Pingback: Samba | Varun's Blog

  21. gary hill says:

    I couldn’t print from windows to my usb printer on my lucid computer until I used your smbpasswd trick above and restarted samba. Now it works like a charm! Thanks for the advice!

  22. P._N. says:

    Jonathan, you made my day!

    after two days and several reinstallations of 10.04 (and some hardwaretrouble besides) your basic instructions solved all XP -> samba trouble and gave me understanding of what I’m doing!

    Was my first ubuntu trial after years of MS$-addiction, now to be solved…

    Gadmin and SWAT nearly broke my nerves, but vi and smb.conf did it in the end, due to your 1st class advices. (the gedit-sudo did’nt work for me…, but original vi came back to my mind…)

    Carry on!

    Pit

  23. Jonathan Moeller says:

    Glad it helped!

  24. Pingback: Sharing folder with Windows network

  25. Sean Jost says:

    After many hours of fiddling with this I figured out my problem was that my password was not complex enough.

  26. shivin says:

    Thanks alot……………

  27. Dean says:

    I’m having, I think, a slightly different problem.

    OK. Networking Problem. Windows 7 can see my Ubuntu laptop on the network. 7 Machine wired to modem/router (327w Linksys). Laptop connected wireless. Can access Ubuntu folders from 7 Machine. Ubuntu keeps asking for username and password even though I’m entering properly to access shares in the Windows folder of Ubuntu. Windows Live Essentials installed on 7 machine, messenger removed to allow me to see others on network. I’d uninstalled all of WLE, and everything worked. BUT, wife insisted on putting everything back but the messenger. I disabled Windows Live Sign in Assistant in the Plugins of Windows Explorer 8. Any workaround for this? PM me if you wish.

  28. Daniel says:

    Hi Jonathan,

    Thank you so much for your Basic Samba Setup On Ubuntu 10.04. Very very helpful my friend.

    Thank you again for your instructions!

    Daniel

  29. Neil says:

    Came here to say that this is just WORKS great! :)

    Tried on freshly installed Ubuntu 10.04 / Dell D630.

  30. Pingback: Basic Samba Setup On Ubuntu 10.04 Lucid Lynx « 海天一色網誌

  31. Paul B. says:

    A very clear and concise tutorial, indeed. I actually can access my share from a Vista box. Amazing. I know there’s a lot to learn regarding permissions, but at least I’ve got a start.

    Thanks very much. Bookmarked.

  32. Jonathan Moeller says:

    Glad it was helpful!

    I have a chapter on permissions in my book, The $0.99 Ubuntu Beginner’s Guide:

    http://www.amazon.com/0-99-Ubuntu-Beginners-Guide-ebook/dp/B004Y1NMDI

  33. Sigurd Mellqvist says:

    First of all, thx for the help, it worked like a charm.

    Second, kindle files open in the same way as pdf on ubuntu? Never tried.. Yes, was thinking of your book. :)

  34. Jonathan Moeller says:

    I have not, as yet, been able to get the Kindle app to run on Ubuntu. However, I’ve had good luck using the calibre program to open Kindle files on Ubuntu (provided they are not protected with DRM).

  35. toto says:

    Hello,
    I appreciate this tutorial and have tried for quite a while to get my 2 Ubuntu’s sharing via samba. I do this so that my XP laptop can get access as well. I am having a very difficult time at it though. Would you please, give me a hand with it?

    Thanks.

  36. loren41 says:

    Previously installed Samba on my host running Ubuntu 11.04. Samba was connected to a Windows 7 host and an unRAID server. When I upgraded to Ubuntu 11.10 I lost the connection to unRAID and don’t know how to get it back. I can connect with both my Verizon network and unRAID, but the Samba configuration is not correct. My smb.conf file looks like this:
    [global]
    ; General server settings
    netbios name = Carolyn-PC
    server string =
    workgroup = WORKGROUP
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192

    passdb backend = tdbsam
    security = user
    hosts allow =

    [homes]
    comment = Home Directories
    browseable = no
    writable = yes

    [share]
    comment = Unixmen File Server
    path = /share/
    force user = samba
    force group = samba
    read only = No
    hosts allow =
    null passwords = true
    username map = /etc/samba/smbusers
    name resolve order = hosts wins bcast

    wins support = yes

    printing = CUPS
    printcap name = CUPS

    syslog = 1
    syslog only = yes

    ; NOTE: If you need access to the user home directories uncomment the
    ; lines below and adjust the settings to your hearts content.
    ;[homes]
    ;valid users = %S
    ;create mode = 0600
    ;directory mode = 0755
    ;browseable = no
    ;read only = no
    ;veto files = /*.{*}/.*/mail/bin/

    ; NOTE: Only needed if you run samba as a primary domain controller.
    ; Not needed as this config doesn’t cover that matter.
    ;[netlogon]
    ;path = /var/lib/samba/netlogon
    ;admin users = Administrator
    ;valid users = %U
    ;read only = no

    ; NOTE: Again – only needed if you’re running a primary domain controller.
    ;[Profiles]
    ;path = /var/lib/samba/profiles
    ;valid users = %U
    ;create mode = 0600
    ;directory mode = 0700
    ;writeable = yes
    ;browseable = no

    ; NOTE: Inside this place you may build a printer driver repository for
    ; Windows – I’ll cover this topic in another HOWTO.
    [print$]
    path = /var/lib/samba/printers
    browseable = yes
    guest ok = yes
    read only = yes
    write list = root
    create mask = 0664
    directory mask = 0775

    [printers]
    path = /tmp
    printable = yes
    guest ok = yes
    browseable = no

    ; Uncomment if you need to share your CD-/DVD-ROM Drive
    ;[DVD-ROM Drive]
    ;path = /media/cdrom
    ;browseable = yes
    ;read only = yes
    ;guest ok = yes

    [MyFiles]
    path = /media/samba/
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0644
    directory mask = 0755
    force user = LOREN
    force group = LOREN
    [test]
    path = /home/Loren/test
    available = yes
    valid users = Loren
    read only = no
    browsable = yes
    public = yes
    writable = yes
    Can you help me?

  37. රනා says:

    Hi,
    I’m from Sri Lanka….
    Its worked for me…
    Thanks a lot man…

    Cheers!!!!!

  38. vidyas says:

    Thanks a lot man… It *just* worked.
    I really had a nightmare to get samba working with read-write permission.

  39. we like your own method of posting blogs. we bookmarked it to my bookmark site set and will feel checking back later on.

  40. cars says:

    It should be fun to buy a new car! Driving a new car
    is such a great experience, and purchasing the car should be
    fun as well. A lot of people would rather skip the whole purchasing
    process. Keep the stress to a minimum using these tips.