The “samba” is a free and open-source implementation of the “SMB Protocol”. It allows the users to seamlessly share files between the operating systems by mounting the shared directory on the remote client. The “samba” server lets the users communicate and share the system’s resources including the Printer and files/directories.
The “samba” came into being in 1991 and it is now a suite of utilities to aid the sharing across the operating systems on a network.
This guide provides the detailed steps to “Install and use Samba on Debian 12”.
Quick Outline
- How to Install and Configure the “samba” Server on Debian 12?
- How to Use “samba” Server From Windows to Linux?
- How to Use “samba” Server From Linux to Linux?
How to Install and Configure the “samba” Server on Debian 12?
The process to install and configure the “samba” server on Debian 12 is as follows:
Step 1: Update System Packages
Keep the system’s packages updated to minimize the installation error. Run the following command to do so:
sudo apt update && sudo apt upgrade -y
Step 2: Install samba
The “samba” server is officially available for most Linux distributions including Debian 12. To install it, use the following command:
sudo apt install samba -y
To verify the “samba” installation, execute the following command:
smbstatus --version
Step 3: Configure the “/etc/samba/smb.conf” File
Although users can use the default configurations of the “samba” server, but for added functionalities, it can be customized. For instance, the default share “homes” is set to read-only and requires configuration to make it writable.
To configure the “samba” server, users must use the “/etc/samba/smb.conf” file. To open it using the nano editor, run:
sudo nano /etc/samba/smb.conf
Add the below mentioned lines at the bottom of the “/etc/samba/smb.conf” file to create a new share “Public”. The “Public” is the name of the share that the remote clients must use to access the files. The share name can be anything according to the user’s choice:
[Public]
path = /home/user/Public
read only = No
guest ok = Yes
force user = user
Here:
- The “[Public]” is the share name.
- The “read only = No” property specifies the “Anonymous” users with only the read/write/execute permissions. Set it to “read only = Yes” to make the “Anonymous” users have only the read permissions.
- The “guest ok = Yes” property makes the “samba” server allow the guest users (Anonymous).
- The “force user = user” property specifies the user that can access the share with all permissions. Use this option if a specific user is unable to connect with the share, otherwise the “guest ok = Yes” does the work.
Step 4: Restart the “samba” Server Service
Restart the “samba” server service and trigger the changes using the command:
sudo systemctl restart smbd
Check if the parameters specified in the “/etc/samba/smb.conf” file are correct, using the following command:
testparm
To enable secure remote access, users must set a password for the share. To set a password for the “samba” server share, run the following command and switch to the “root” user:
sudo -s
Now, execute the below command, replace the “user” with your username and set the password:
smbpasswd -a user
To switch back to the current user, run the below command:
exit
Step 5: Locally Test the “samba” Server
To test whether the “samba” server is working correctly, users must install the “cifs-utils” via the following command:
sudo apt install cifs-utils samba-client -y
After that, run the following command and replace the “user” with your username to check the working of the “samba” server. If the command runs successfully, users can use the “help” command to view the useable commands for the “samba” server:
smbclient '\\localhost\Public' -U userhelp
How to Use “samba” Server From Windows to Linux?
First, configure your “samba” server following the above-stated steps and press the “Windows + E” keys to open Windows Explorer. Right-click the “Network” from the right panel and select the “Map network drive…” option:
Now enter the IP address followed by the share name in the below-stated format:
\\<IP>\<Share-Name>
Next, enter the login credentials to connect (set in the “samba” server on Debian 12):
After the successful Network Mount, users can access the “samba” server share from their Windows PC:
After connecting, we created a “New folder” in the shared directory to test the working of the “samba” share. To view the contents of the shared folder, run:
ls /home/user/Public
How to Use “samba” Server From Linux to Linux?
The “Other Locations” allows the users to access the “samba” share on the server. To access it, open the “Files” or other default file manager and at the bottom find the “Connect to Server” option. Use the following format to connect with a remote “samba” server:
smb://<Your samba Server's IP Address>/Share Name/
After hitting the Connect button, users are prompted to enter the credentials. Login using the credentials created earlier for the “samba” server on the remote server. After the successful login, the following screen appears where users can share and find the shared directories/files on the remote server:
That’s all for installing the “samba” server on Debian 12.
Conclusion
The “samba” server implements the “SMB” or “Server Message Block” protocol. It uses the client/server architecture to share files/directories and printers between Windows, Linux, and macOS operating systems.
You can use the “samba” on Debian 12 by installing it first via the method stated above.
To configure the “samba” server on Debian 12, use the “/etc/samba/smb.conf” file. After opening the file, follow the above guide for a detailed explanation of the customizations that you can do. This guide has discussed the process of installing and using the “samba” on Debian 12.