How To Install SAMBA Server on Debian

How to install SAMBA server on Debian Linux and access from Windows 10.

What is Samba?

Samba is an open source implementation for Linux environments of the Server Message Block (SMB) protocol which allows connections to be established between Windows, Linux and UNIX networks with full compatibility.

Now we will see how to install and configure Samba on Debian 9.

Before Installing SAMBA

Before installing and configuring Samba in Debian 9, we will perform the following tasks for the optimal functioning of the connectivity between Linux and Windows.

1. Installing the nano editor

To edit the Samba configuration files, we will install the nano editor by executing the following line:

apt-get install nano

2. Enable the Debian server in Windows

To be able to access from Windows to the Samba server in Debian we must edit the Windows hosts file.

To do this, we will open a console of the command prompt as administrators and execute the following line:

notepad C:\Windows\System32\drivers\etc\hosts

This will open the hosts file as an administrator for editing. There we will add the next line: TheLinuxCode.debian debían

In this case, it will be necessary to edit the IP address by the current server of each one and establish the correct hostname. Finally, save the changes in the Windows hosts file.

Install SAMBA on Debian 9

We will access as root users in Debian 9, and we will execute the following line for the installation of Samba:

apt-get -y install libcups2 samba samba-common cups

Next, we will move the file smb.conf to smb.conf.bak to have its initial configuration in case of any error; we will execute the following command:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Create Samba Configuration File

Now we will create the configuration file for Samba by running the next line:

nano /etc/samba/smb.conf

In the new file we will add the following lines:


workgroup = WORKGROUP

server string = Samba Server %v

netbios name = debian

security = user

map to guest = bad user

dns proxy = no

Note: The workgroup field must be assigned with the correct name of the Windows workgroup.

To check the name of the workgroup in Windows, we will execute the following line at the command prompt: net config Workstation


Save the changes using the keys Ctrl + O, and we left the editor using Ctrl + X

Restart the Samba services by executing the following line:

systemctl restart smbd.service

Create Shared Folder on Debian

Now we will create the directory to share the files between both systems, and we will change the group to the user group, for this we will execute the following lines in their order:

mkdir -p /home/shares/allusers

chown -R root:users /home/shares/allusers/

chmod -R ug+rwx,o+rx-w /home/shares/allusers/

mkdir -p /home/shares/anonymous

chown -R root:users /home/shares/anonymous/

chmod -R ug+rwx,o+rx-w /home/shares/anonymous/

Now we will access the Samba configuration file by running the next line:

nano /etc/samba/smb.conf

There we will add the following lines at the end of the file:

Group to share

This indicates a shared resource which is accessible and writable for all members of our “user” group. We will add the following:


comment = All Users

path = /home/shares/allusers

valid users = @users

force group = users

create mask = 0660

directory mask = 0771

writable = yes

Home Directory

There we allow users to read and write in their directories through Samba; we will add the following lines:


comment = Home Directories

browseable = no

valid users = %S

writable = yes

create mask = 0700

directory mask = 0700

Anonymous directory

Here we allow all users to write and this option is open to anyone in the network so it should be managed only in local networks, we will add the following:


path = /home/shares/anonymous

force group = users

create mask = 0660

directory mask = 0771

browsable =yes

writable = yes

guest ok = yes

Save the changes using the keys Ctrl + O, and we left the editor using Ctrl + X.

Restart Samba to apply the changes:

systemctl restart smbd.service

Manage SAMBA Users on Debian 9

The next step is to add the users we want for the connection through Samba, for this we will create the user solvetic1 executing the following:

useradd solvetic1 -m -G users

We can add the desired users. We will modify the password using the passwd solvetic1 line. 
Now we will add this user to the Samba database by executing the following:

smbpasswd -a solvetic1

Access Samba From Windows

In this case, we are running Windows 10 and to acess the Samba server we will use the following key combination and enter the server IP: Win + R

When pressing Enter or Accept we have accessed the folders that we have created in Samba:

When trying to locate any of the available folders, we must enter the credentials of the authorized user that we have created, in this example solvetic1:

Click on Ok and we will have access, and we can create or edit objects there:

Thanks to Samba it will be possible to share files in a compatible and straightforward way between Windows and Linux.

Similar Posts

One Comment

  1. I did exactly like it was written in tutorial on clean debian 9 installation but unfortunatelly folder allusers du not work: I see promt to enter login/pass again and again

Leave a Reply

Your email address will not be published. Required fields are marked *