Debian

How to configure Samba in Debian

We are working in an office, there are more than 100 employees, many employees have to make some files and forward to it senior for the approval or for proofreading, so instead of that they take a bundle of files and pass it to the senior person it’s better they just send these files to them on a single click by using Samba. Yes! It enables many users to share files with each other instantly and with a single click if all the users are connected to the same network.

Samba is a networking tool that is used to connect Windows and UNIX, with the help of this connection we can share files between UNIX and Windows. It can also share the printers installed on the server of the windows client.

This guide helps us to understand the installation of Samba as well as to set up its configuration settings.

How to install and configure Samba on Debian

Before the installation, we will update the packages list.

$ sudo apt update

Now we will install the Samba on Debian:

$ sudo apt install samba -y

Samba configuration can be found in /etc/samba/smb.conf. It contains all the configuration settings for itself and for the files which have been shared so is known as Global Settings. Open the path by using the nano command.

$ sudo nano /etc/samba/smb.conf

The output should look like this.

Some settings are in the configuration file that should be discussed before making any modifications. The first setting you will see is the workgroup which tells you to which operating system you are connected. By default it is WORKGROUP but if you want to connect with some specific group then you can change it. The next one is an interface, it will tell you which IPs are allowed by you to connect with the samba network, so by this setting, you can make your samba secure that all the devices cannot connect to it only a few ones can connect to them which are allowed by you.

Next is share definitions, here by default some user directories are present like the home directory and the printer directory, with which the files can be shared using the Samba.

Now we will try to create our own user, for this enter the user name; in our case, we choose [New_share] as the new user:

[New_share]

In the next line after the four spaces describe the new user as:

comment= my share

Set the path to be shared for example:

path = /home/user/share

Now tell it whether you will browse it to the share or will mount it manually:

browseable  = yes

Now set the settings either it will be readable only or can be edited by other people:

Read only = no

You can set the password so the anonymous user, the user outside the network server, cannot access it and you can also not set the password so they can use it:

guest  ok = no

If anonymous people cannot access it, then allow the user who can access it.

valid users = maadi

Now press CTRL + X then type “y” and press ENTER key to save and exit the editor. After all, this restarts the Samba.

$ sudo systemctl restart smbd

Go to the root user mode by:

$ sudo -s

And set the password for the Samba. You can replace the maadi with your username, type a password then confirm it by retyping, and when the user is added so type exit so that the root user mode terminates. In the command flag “-a ” is used to add the user.

# smbpasswd -a maadi

There are some packages that are to be installed so that we can connect to the newly created user.

$ sudo apt install cifs-utils samba-client -y

Open the files of Debian, go to the network, and choose Debian.

The share, New_share is visible which we have created.

Now we can share files from any Linux machine to the new user if the user is a member of the same LAN.

Conclusion

We can add the single printer to the LAN so anyone (who is allowed) can print the documents from his/her own computer. In a company, the staff communicate with each other through the local area network, by adding the users so they can access the folders of any other computer and copy files from there without physical movement, this type of assistance can be done by using different software in Linux and Windows; one of the renowned utility for this purpose is Samba. In this writeup, we have discussed how to install samba in Debian and also configured it by making a share file using it.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.