Official website for Linux User & Developer
FOLLOW US ON:
Jul
27

Build a Samba file server

by Sukrit Dhandhania

How to build your own file server using Samba and Ubuntu with help from Linux User & Developer veteran, Sukrit Dhandhania…

08 Add the directory to Samba

[commonshare1]
 comment = Ubuntu File Server Share
 path = /opt/commonshare1
 browsable = yes
 guest ok = yes
 read only = yes
 create mask = 0755

Here’s what these parameters mean:
comment – This is the text that appears as a description of this share.
path – The file system path of the shared directory on the server.
browsable – ‘Yes’ or ‘no’ determines whether users can browse through the contents of this share or not.
guest ok – ‘Yes’ or ‘no’ determines whether a user requires authentication to access this share or not.
read only – ‘Yes’ or ‘no’ determines whether users can write to this location or just read from it.
create mask – The permissions that new files will have when created.

09 Test the new share
Save the Samba configuration file and restart the Samba service with the command ‘# sudo /etc/init.d/samba restart’. The service should restart pretty quickly. Now try accessing your Samba server from another computer on the same network as your server. From a Windows machine you should be able to access your new share by going to the URL ‘\\192.168.1.3\commonshare1\’. Replace the IP address with the one assigned to your server. You should be all to log in without being asked to enter a password, and be able to browse through the files inside. Also check to make sure that you are not allowed to upload anything to this location.

10 Share with read and write
Create a new directory, ‘/opt/commonshare2’. Open the Samba configuration file and copy the configuration for the last share directory and paste it underneath it, leaving a blank line. Make one configuration change other than the new name and the directory path: delete the ‘read only’ line and replace it with ‘writeable = yes’. Your settings will look something like the following:

[commonshare2]
 comment = Ubuntu File Server Share with Write
 path = /opt/commonshare2
 browsable = yes
 guest ok = yes
 writeable = yes
 create mask = 0755

Save the configuration file and restart Samba. Access the new share by going to the URL ‘\\[YOUR-IP-HERE]\commonshare2\’. You should be able to browse, read and write to this location without any authentication.

11 Users
Samba offers several ways to enable user management. If you want, you can have Samba authenticate users against a list maintained by an Active Directory or an LDAP server, or you can use other options. The way we have configured Samba is that it uses the Linux server’s user list, maintained in the ‘/etc/passwd’ file to authenticate users. So you need to be a system user to be able to log into a Samba share if the authentication has been enabled on it. If you have a system user ‘calvin’, you can enable Samba access for this user by setting up a Samba password for it.

# sudo smbpasswd -L -a calvin
# sudo smbpasswd -L -e calvin

Next Page

twitter follow us
Pages: 1 2 3 4 5 6
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.

    2 Comments »

    • jkneb said:

      Hi, great article, very instructive.

      And what about accessing the samba share from outside of the network ? Let’s say I’m at work and I would like to access my samba share wich is on my home network IP adress.

      Any idear ?

      Again great article :)
      Cheers
      Julien

    Trackbacks

    What's your opinion?

    Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

    Be nice. Keep it clean. Stay on topic. No spam.

    * Required fields