| by Arround The Web | No comments

How to Install Samba on Debian 12: A Step-by-Step Guide

Samba is an open-source software suite that allows you to seamlessly share files, folders or other important data between Windows and Unix-based systems (Linux and macOS). It is like a bridge that connects your system to another system no matter what operating system you are using. It is one of the secure ways for remote sharing since it supports various authentication methods that help secure access to data.

If you are a Debian user and searching for an easy and quick way to share files and folders to other systems, you must choose Samba.

In this guide, you will find:

How to Install Samba on Debian 12

Samba is available in the default Debian 12 repository and can be installed directly with the required dependencies using the apt command given below:

sudo apt install samba samba-common-bin -y

How to Set up Samba on Debian 12

After installing Samba on Debian 12, you must take some additional steps so that you will be able to share files or folders from one computer to another. The steps to set up Samba on Debian 12 are provided below:

Step 1: Create Samba Directory

For better organization of your files, directories and to protect your system privacy, it is recommended to create a new directory. You can use this directory as a Samba shared directory.

Here, I have created a directory with the name samba_dir_debian on Debian 12 using the mkdir command:

mkdir samba_dir_debian

Step 2: Configure Samba on Debian 12

You must need to configure Samba on Debian to allow sharing files between the server and the client. You can open the configuration file of Samba on Debian using nano editor from the following command:

sudo nano /etc/samba/smb.conf

After opening the file, add the following lines by replacing the path with the location of the directory you want to share:

[linuxhintsamba]

path = /home/linux/samba_dir_debian

writeable=Yes

create mask=0777

directory mask=0777

public=no

Note: [linuxhintsamba] is a point that you will use later on while accessing the directory, it is actually the name of the shared folder so you can write any name you want. Once done, save the Samba configuration file using CTRL+X, add Y and press Enter:

Step 3: Set a Password for Samba on Debian 12

You must set a strong password for the Samba server as an additional security measure, this password will be used when you connect to the server from another computer. To set a password for Samba on Debian 12, use the following command:

sudo smbpasswd -a username

Note: You must add your Debian system’s username in place of username keyword in the above command.

Step 4: Restart Samba on Debian 12

After configuring Samba and setting the password, you should now restart Samba service on your Debian system through the following command:

sudo systemctl restart smbd

Step 5: Check Samba Status on Debian 12

Ensure Samba server has an active status on Debian, this can be done from the following command:

sudo systemctl status smbd

How to Connect Debian 12 to Wi-Fi on VirtualBox

If you are using the Debian system on VirtualBox, then it is recommended to connect your system to the Wi-Fi network. This will allow you to use the IP address of the system and quickly connect to it through Samba.

To connect Debian to Wi-Fi on VirtualBox, use the following steps:

Step 1: Open VM Settings

First, right-click on the Virtual Machine where you have set up Samba, then click on the Settings option:

Step 2: Change Adapter Attachment

Now, head towards the Network section and replace NAT with the Bridged Adapter by selecting it from the list:

Step 3: Select Adapter Name

Choose the Adapter name from the list, which is Broadcom 802.11n Network Adapter in my case, then select the OK button:

This will connect your system to Wi-Fi, you can verify it by running the following hostname command:

hostname -I

Note: You can skip this method if you have installed Debian on your system instead of installing it on VirtualBox.

How to Use Samba to Share Files with Debian 12 and Windows

If you are using Windows system, you can use Samba to share files with Debian and Windows using the following steps:

Step 1: Open Windows explorer and click on the Computer option at the top:

Step 2: Then choose the Map network drive option:

Step 3: At the Map Network Drive windows, enter the address in the following way:

\\IP_address\shared_folder_point

Here, in place of IP address, use the IP address of your Debian system, while replacing shared_folder_point with the name you set it in Step 2 of the setup method. After adding the desired address, click on the Finish button to start connecting to the server:

Step 4: Enter the username and password that you set for Samba server:

Once you provide accurate information, you will be able to see your shared folder on your Windows system. This shared folder is directly linked with the directory you have created on Debian 12:

You can confirm it by copying any file from your Windows system and paste it in the network directory on Windows.

Once done, you will see that the file is successfully shared to Debian as well, confirm it using the ls command within the directory:

ls

 

How to Use Samba to Share Files with Debian 12 and macOS

On macOS, you can share files with Debian 12 using the below-given steps:

Step 1: Navigate to Connect to Server option from the Go menu on macOS:

Step 2: Enter the address in the following way, then click on the Connect button:

smb://IP_address/shared_folder_point

Note: If you are unable to access the folder, you must allow file sharing on Mac from the Sharing option.

Step 3: Enter the username and the Samba password, then click on the Connect button:

Step 4: Again, click on the Connect button one final time:

This will connect you to the Samba server on Debian 12:

How to Use Samba to Share Files with Debian 12 and Linux

If you are using other Linux system alongside Debian 12, you can use the following steps to use Samba for sharing files with Debian and Linux:

Step 1: First, install Samba client on your other Linux distros using the apt install command provided below:

sudo apt install cifs-utils samba-client -y

Step 2: Then open Linux explorer and navigate to Other Locations:

Step 3: Enter your server address in the Connect to Server column and then click on the Connect button:

smb://IP_address/shared_folder_point

Step 4: Then, use the Registered User option, enter Samba server’s username and password (Samba password). You can choose any option from the password section and once done, click on the Connect button:

This will open the Samba shared folder on your Linux system:

Conclusion

Samba is a useful program that allows sharing files and folders to another system. You can install Samba on Debian 12 with its required packages directly from the apt repository. However, you will need to set up Samba from the configuration file, add a password and choose the system where you want to access the shared folder. Accessing the Samba shared directory is different on Windows, macOS or Linux systems and can be followed from the above-sections of this guide. After accessing the shared directory, you can transfer files from one system through another using the shared directory as a communication bridge.

Share Button

Source: linuxhint.com

Leave a Reply