RSS

How to share a folder with Read/Write access using Samba on Linux

Tue, Aug 29, 2006

ArsGeek, Linux, Ubuntu

Talk about it in our Forums

Samba Baby!

Here’s my setup. I’ve got a large network that’s accessible by hordes of people. On this network I have an Ubuntu box acting as a file server. I want a limited number of folks to be able to put files on it, take files off of it and access it from a number of different operating systems (OSX, Windows and Linux). How to do that? Well, the unix folks can use ssh and scp to connect and move files around (as can the more advanced windows folks :) )but for graphical sharing or mapping a network drive via Windows, we need Samba to get involved.

Put on your red cape, your spandex pants and your big “S” shirt. Then take a pic of yourself and send it to me. When you’re done doing that, we can install Samba.

sudo apt-get install samba smbfs

Now that we’ve got samba installed, let’s create a local user with which people can log in with.

Go to System-> Administration-> Users and Groups.

I created a new group (for this demonstration, I’ll call it newgroup) and a new user (let’s call it newuser). Add the new user to the new group. I’m not going to go through every step of the gui as it’s very straightforward.

Now that you’ve got a group and user, let’s give them access to your samba share.

sudo smbpasswd -a username

gedit /etc/samba/smbusers

Now, in the smbusers file that you’r editing, add the following:

username = “username”

Here, the first username represents the local user, and the second username, in quotes, represents the samba user. Save the file and exit Gedit.

Now you’ve got Samba installed and running, and are ready to create a folder to share. We’ll call this folder ShareMe for this example.

sudo mkdir /home/ShareMe

sudo chmod 777 /home/ShareMe

sudo cp /etc/smb/samba.conf /etc/smb/samba.conf.bak

sudo gedit /etc/samba.conf

Now, we’ve created the directory and we’re going to add a bit to samba.conf to let the samba know what folder it should be sharing, and to who. First find the line “security = usr” and replace it with:

security = user

username map = /etc/samba/smbusers

Then add the following to the bottom of the file:

[ShareMe]

comment = Public Folder

path = /home/ShareMe

public = yes

writable = no

create mask = 0777

directory mask = 0777

force user = nobody

force group = nogroup

Now let’s restart Samba and give it a whirl.

sudo /etc/init.d/sambe restart

Once the daemon restarts, head on over to a windows machine and attempt to connect by going to Start-> Run and entering in:

\\pathtoyourcomputer\ShareMe

And that’s how to set up samba sharing.

geek out.

Technorati Tags: , , ,

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

6 Comments For This Post

  1. Pe Bakk Says:

    Followed the steps exactly and it just allowed read-only access from the Windows computer.

    I’m running Ubuntu Feisty 7.04

  2. flinn Says:

    it should be /etc/init.d/sambA (not sombe) restart

  3. Skatox Says:

    writable must be set to yes to work.

  4. matt Says:

    I followed this tutorial and it worked fine, but at work I had trouble because our server was using SElinux, if you want to you can get around SElinux, and your firewall with the GUI tool system-config-securitylevel
    It works great on one hand, but if you don’t know about it, it is killer on the other.

    mbs

  5. Jim Says:

    I was going great, until I got to the gedit part. It said I did not have privileges, even though I am an administrator.

  6. fkili Says:

    it’s not work with windows client ,make a solution for write something in a shared folder from a windows smb client

1 Trackbacks For This Post

  1. ArsGeek :: Using Hamachi to remotely control your Windows and Linux boxes Says:

    [...] Once you have systems on Hamachi, you can connect to them in any way you normally would (i.e. ssh, scp, samba or windows shares). Hamachi is interesting because it offers a central location where you can see all of your machines, as well as encryption to help protect your privacy. [...]

Leave a Reply