File sharing on Linux


The following tutorial will show you how to set up samba on a Linux system allowing you to share files and folders with a either a Linux or a Windows client.  All the following steps work on Linux Mint 11 but should also work on any other distribution using gnome.  For kde the only thing which differs is defining shares (usually through the kde control center).

On the Samba Server

First thing is to check samba is installed.  Open up a terminal and type:

sudo apt-get install samba

Type your root password when prompted.  Then install smbfs by typing:

sudo apt-get install smbfs

and then type your root password again.

Now open up your smb.conf file by typing:

gksu gedit /etc/samba/smb.conf

Locate the line WORKROUP = WORKGROUP and change it to the name of your network.  So for instance mine would be changed to WORKGROUP = MINT_HOME.  Save the file and exit.

Now we have to add users to the smbpasswd file which is located at /etc/samba/smbpasswd.  Only users specified in the smbpasswd file will be able to access your samba shares.  Open a terminal as root and type:

smbpasswd -a user (where user is the name of the person allowed to access the shares).  When prompted enter their new password twice.

Next we have to define the samba shares.  Type:

sudo shares-admin

With the GUI open add your samba shares, save and exit.

Note, everytime you update the smb.conf file you must restart the samba service so type:

sudo service smbd restart

Now we have to check the configuration so far.  Type:

testparm

If there are errors in the xorg.conf file testparm will tell you.  If everything is Ok then type:

smbclient -L 192.168.1.10 (where 192.168.1.10 is the ip address of your samba server).  This will show you the list of all your available samba shares.  At this point if you have no errors your server is configured correctly.

Linux Clients

Install smbclient and smbfs either using the package manager or apt-get install.  Now we have to mount the available shares.  First decide where you are going to mount them.  I will mount them in /media/dev/share but first I will have to make the directory dev so:

cd /media

sudo mkdir dev

and then ls which should show us the new dev directory in media.  Now time to mount the shares.

sudo mount -t smbfs //192.168.1.10/(share name) /media/dev/share where 192.168.1.10 is the ip address of your samba server.  This will mount the share but only as long as you are logged in.  To make the link persistent you need to enter the following line into /etc/fstab.

//192.168.1.10/(share)   /media/dev/share      cifs       username=user,password=pass,user,rw,noatime     0              0

Windows Clients

We have to change the workgroup to MINT_HOME and then add the ip address of the samba server to the hosts file (must open as administrator).

Once this is complete map the shares to your computer.

Word of warning here about firewalls.  Either turn them off or add exception rules for traffic on ports 137-139 and 445.

About the Author

Hi I am Chris the owner of ComTech. I provide IT Support, Laptop repairs and Computer repairs to both personal and business clients in and around Stirling. For a list of what I can offer you why not visit my website www.comtech247.net where you will find my blog, testimonials, services and much more.  Start supporting a local business today so I can start supporting you.

If you found this blog useful then why not sign up to my RSS Feed for news, tutorials, views and general techie stuff!!

 

This entry was posted in Blog and tagged computer repair, comtech, how to, IT Support, laptop repairs, linux, samba, stirling, windows. Bookmark the permalink.

5 Responses to File sharing on Linux

  1. Kilian says:

    Undeniably believe that which you stated. Your favorite justification seemed to be on the web the easiest thing to be aware of. I say to you, I certainly get irked while people think about worries that they plainly don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks

  2. Lane says:

    Lovely information, wonderful page template, continue the good work

  3. Marcelino says:

    Greetings I found your page by mistake when i was searching Live search for this concern, I have to point out your website is truly very helpful I also really like the theme, it is great!

  4. Chris says:

    When sharing files I would always recommend using samba with Windows clients as it just works (Samba is based on smb which is a Microsoft protocol). Yes NFS is faster however you will run into issues if you try and use this with a mixed client network. On a Linux network NFS rules!!

  5. richard258 says:

    So why use this over NFS?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current month ye@r day *