Samba is a powerful open source tool that allows you to share files and printers over a network on Windows-style Linux systems. It allows Linux and Windows computers to coexist and interact on the same network. It is installed on a Linux server that hosts files for sharing. These shared files can then be accessed by any authorized Linux or Windows client on the same network.
This article explains how to install and configure a Samba server on a Debian system. We’ll also learn how to access these shared files from Linux or Windows computers.
We used Debian 10 to execute the commands and procedures mentioned in this article. However, the commands and procedures work in much the same way on other Linux distributions.
Installing Samba on Debian
Launch Terminal on your Debian OS. Click the Actions tab in the upper left corner of your desktop. Then enter the keyword terminal in the search bar. When the search result appears, click the terminal icon to open it.
In Terminal, enter the following command to install the Samba server.
$ sudo apt install samba
He may ask for confirmation by giving you Y / N option. Hit Y to continue with the installation process and Samba will be installed on your system.
During installation, it may ask if you want to use the WINS settings from DHCP. If your server is using a static IP address, select NO.
Checking SAMBA Installation
To verify the installation, check the status of the samba service “nmbd”. This service starts automatically after samba is installed.
$ sudo systemctl status nmbd
If samba server is installed and running successfully you will see Active (running) status.
If the service does not start automatically, run this command to start it manually:
$ sudo systemctl start nmbd
After completing the installation of the Samba server, it’s time to configure it. The samba smb.conf configuration file is located at / Etc. / samba catalog. In this file, we specify the folder and printers that we want to share, as well as their permissions and operating parameters. Samba looks at its configuration file after a certain amount of time and updates any changes.
Follow these steps to complete the settings:
Step 1: Create a directory for sharing files over Samba. This directory will store the files you want to share. Run the following command to create a new directory in the root directory.
$sudo mkdir /samba
Step 2: Now we will need to edit the smb.conf configuration file. Before editing a configuration file, be sure to back up this file in the same or a different directory. Run the following command to back up the smb.conf file.
$ sudo cp /etc/samba/smb.conf ~/Documents smb_backup.conf
This command will create a backup in ~ / Documents directory
Step 3: Now edit the source config file using any text editor like Vim, Nano or Gedit. We are using the Nano editor here:
$ sudo nano /etc/samba/smb.conf
Scroll to the bottom of smb.conf and add the following lines:
[samba-share] comment = Samba on Debian path = /samba read-only = no browsable = yes
- [samba-share] = name of the samba share
- comment = short description of the action
- Path = The path to the shared directory.
- Read only = Make shared directory readable
- Browsable = whether to share the share or not
Then press Ctrl + O and Ctrl + X at the same time to save and exit the file.
Setting up a user account
Now we need to set up a user account for samba. The Samba user must be a system user and therefore must exist in / Etc. / password file. If the user doesn’t exist yet, you will need to create one first. Otherwise, just execute the command in Terminal using the following syntax to set a new password for the user.
$ sudo smbpasswd -a username
Restart Samba service
When you are done with all the configurations and user settings, restart the Samba service by running the following command in Terminal:
$ sudo systemctl restart smbd.service
Mounting a Samba Share from a Linux Machine
Using command line
To mount the samba share from the Linux command line, you need to install the Samba client. This will help you connect samba shares from the command line.
Run the following command in Terminal to install the Samba client:
$ sudo apt install smbclient
After installation, connect to the Samba share using the following syntax:
$ sudo smbclient //[IP_address or Host_name]/share_name –U samba_user
- [IP_address or Host_name] this is the IP address or hostname of the Samba server
- [share_name] this is the name of the Samba share
- [samba_user] the name of the user who has access to the share
As soon as you enter the command into the terminal, it will ask you for a password. Enter your password and press Enter, then you will see samba CLI. To view the supported commands in the CLI, type help and press Enter.
Using the graphical interface
To access the Samba share through the GUI, open the file manager. At the bottom of the file manager window, you will see the icon Connect to server option. In the address bar, enter the address of the Samba server in the following format and click Connect.
//[IP_address or Host_name]/share_name
When the following window appears, select the radio button Registered user and Enter your username and password in the appropriate fields. If you are in the WORKGROUP environment, leave Domain default box and click Connect,
You should now be able to access shared files on the Samba server.
Method 2: Mounting a Samba Share from a Windows Computer
On Windows Run The utility is mainly used to access shared files over the network. To open the Run utility, use Windows Key + R label. When the utility opens, enter the shared Samba address in the following format and click WELL.
You will be prompted for the password for the Samba user. Enter your password and click well,
You should now be able to access the shared Samba files on your Windows computer.
In this article, we learned how to install Samba on a Debian 10 system. We also learned how to connect to a Samba server from Linux and Windows machines to access shared directories.
How to install and configure Samba on Debian 10