Samba – software for running the so-called file server on Linux. It is compatible with Windows, so it is very widely used in companies, universities, institutions, factories, and even banks. It is characterized by very high security and stability work. In this article I will describe how to install and configure Samba on the Linux distribution Ubuntu example.
It can only write briefly what in practice may be useful to us samba, and so let’s assume that we have a class such as IT, where there are 20 computers with Windows XP, it is known that the class teacher will want to share with other various files. Having a computer with Linux and Samba, will put these files on the server and make them available to students. There is also irrelevant whether the student will work on Windows or Linux, everyone will have access to these files.
Another interesting example is using a file server for accounting software, such as the symphony, which lets you work on a number of accounting database. It would also create a regular backup important data, and protects them against such viruses. Applications is very much, you yourself should know what to use samba:)
Installing Samba
Let’s start with installing samba on our server. As this is a very popular software, virtually every distribution is ready to install packages in the repositories, so just install it from them. If Ubuntu is simply the command:
sudo apt-get install samba
After a while we have the service installed on your computer. Her name is system smbd and nmbd, we will need it later. Let’s get to the most important part, or configuration.
Samba configuration
The main Samba configuration file located in the following location:
/etc/samba/smb.conf
file is owned by root, so for any changes we will need admin rights. The most convenient way is to simply log on as admin fixed:
sudo su
a program to edit the file:
nano smb.conf
This file is quite bulky, so we spend a moment in determining the optimal configuration. I will here consider only the positions that we are most interested in, here we go:
The file is accompanied by commentaries in English, which should help us quite well, mind you, that the lines starting with # and, are inactive.
[global]
in this section, we are setting global for all users.
workgroup = WORKGROUP
we set the group name in Windows, it is best to set such a group you have other computers on the network, in a default installation of Windows, version com, it is: WORKGROUP
server string = %h server (Samba, Ubuntu)
under this name you will see the server in a network environment.
security = user
very important setting, determining who can use the file server, for user settings, anyone who wants to download something from our server, you will have to be on it’s own account, but if you set the share, there is no need. This option should uncomment (remove the #).
encrypt passwords = true
if you set security = user, the above entry makes the user’s password is encrypted, this option may cause some problems, but I will write about it later.
passdb backend = tdbsam
in case the encryption password, the above option determines where you will be saved encrypted password.
map to guest = bad user
option makes all the people who do not log in as user samba, will have the right guy.
Share Definitions Division is responsible for the directories that you want others to share, we can specify their rights also, eg read-only attribute.
Security share
We shall first consider the situation where we do not want to create any users, and you just want to make everything else on the network your files. It is in this case, the configuration, set security to share. It’s not the end, unfortunately, the default samba config with Ubuntu is quite felerny and should be improved. Primarily missing several important lines, just add them and discuss. First, let’s change the options that are already, ie:
workgroup = WORKGROUP
server string = Samba
security = share
Then add the additional options at the beginning of Config, I put them in front of me ruler # # # # Networking # # # # (must be in the [global]), and they look as follows:
# My additional settings
netbios name = Samba
browseable = yes
local master = yes
domain master = yes
netbios name – the name of our server, which will be displayed in a network environment
browseable – without this option, your server will not be visible at all in a network environment
local and domain master – required for proper communication between the server and clients
Suppose we want everyone to share a folder “shared”, located in your home directory, so the path looks like this (my user name is qlwik):
/home/qlwik/shared
So we add the following entry at the end of the samba configuration file:
[shared]
comment = shared
path = /home/qlwik/shared
browseable = yes
writable = no
create mode = 0644
directory mode = 0755
guest ok = yes
comment – the name of the shared resource
path – the path to it
browseable – determines whether the resource can be viewed
writable – it determines whether you can save and edit files
create mode – determines what permissions are newly created in the files
directory mode – refers to the rights of created folders
guest ok – an important option, without it we will still showed login window in Windows, when you will want to open a resource, and still do not log on because I did not created any users yet.
Then restart Samba commands:
service smbd restart
nmbd restart service
After a while, our server should already be visible in a network environment called Samba, if we get him, we should see in the folder “common”. In its current configuration, but this folder is read-only so that others can write something here should do some changes. First, you must change the permissions to the directory on the server at 777, namely:
chmod 777 /home/qlwik/shared
then in the Samba configuration file (with options for resource [common]) need to change one line, namely:
writable = yes
After restarting Samba, everyone will have the right to write, modify and delete files in it.
If you’re planning to share all printers installed on the server, simply by shares [printers] and [print $] to change:
guest ok = yes
Note: In some Linux distributions, you must also unlock the Samba ports in the firewall, if any, is installed.
Note 2: If there are any zacinki and pendants in conjunction with Samba, sometimes you restart the network connection to the client.
Security user
Now let’s see how the security = user option. In this case, to view any stocks, you need a username and password. Start by creating a new user in Linux, Ubuntu can do this by choosing the menu:
System -> Administration -> Users and Groups
for example, by adding Marian and his password is 123456, you now need to add samba to the database, type in the console:
smbpasswd-a Marian
give 2 times the password, which is 123456, the user has been added, now we go to the configuration file, change the option, of course:
security = user
after saving and restarting samba Config, Windows will display the login window, when we want to go to the server. Let us now come to a shared directory, enter the username and password, and try to save something in it. If the directory “joint” has a 777-level permissions and have the option to the config file writable = yes, then we will be able to do so, however, is but one. The newly created file will have the owner mariana, and will be read-only for others to change it, change the following options in the configuration of samba:
create mode = 0777
directory mode = 0777
thanks to all files and directories created will have default permissions 777th
Mapping drives in Windows
A very convenient way to use resources provided by Samba is mapping a network drive. It consists in the fact that the shared folder will be available in “My Computer” as an additional drive, such as X:. Present here a method that also works well on kompach with Windows XP Home, which drives the mapping has been blocked.
Create a text file on your desktop and edit it. Here, type:
net use z: \\192.168.0.100\wspolne /user:marian 123456 /persistent:no
Of course, enter here the IP address of our server with samba. Instead of an IP address can also specify the server name appears in a network environment, but I do not recommend, as observed in this case, some problems with communication between machines. Save the text file created, and then change its extension from txt to bat. If you do not see the extension you can change this setting in Folder Options. Put the file to the startup and restart Windows. After reboot should show in “My Computer” the new drive by the sign Z: \ \, leading to a folder, the documents on which we have all the rights, read and write. This way you can configure several kompów, so that they gain access to the same folder.


