Saturday, November 7, 2009

How to set up Samba server

Imagine, that you have a computer running linux (e.g. home server) and you would like to share some files with your windows computer. Now you have two possibilities. You can either install nfs client on your windows computer, or a samba server on linux. Today we will have a look on how to set up a samba server on your linux system.

First you will need to install the samba itself. This differs a lot according to your distribution, but on debian I would do simply

apt-get install samba

Now, that you have the samba installed on your computer, it's time for the funny part, the configuration. The main configuration file of samba should be /etc/samba/smb.conf. It will be filled with some default data, but I recommend you to delete this file and start writing a new one with your favourite editor.

rm /etc/samba/smb.conf
nano /etc/samba/smb.conf

Now fill your new file with this:

workgroup = MASLIK.CZ
server string = samba server
browseable = yes
hosts allow = 10.0.0.
security = user
hide dot files = yes

path = /export
browseable = yes
writable = yes

 This is the very basic configuration. You should of course fill your own values to workgroup and hosts allow in the global part. After that part we define all of our shares. I have one folder defined. For windows clients it will be shown as a sharing folder (the [sharing] string manages this), but the real folder shared is /export. You may of course also set writable = no, if you wish to have a read-only folder.

After changing the configuration file you should restart the samba daemons, if you are not planning to restart your computer.

/etc/init.d/samba restart

Now the last step, you have to take is to make a new samba password for any user, that will have access to your samba server. You will do that by this command:

smbpasswd -a user

After entering this command you will be prompted to enter the new password. This would create a password for user user, so fill your own username. Finally you may also like to use chmod to update the access rights to your shared folder.

So I wish you good luck with setting up your server. Samba of course gives us many more possibilities of settings. One of the most important is a printer sharing. We will have a look at that next time.

No comments:

Post a Comment