How to Install Samba on Debian

Samba is a free and open-source software tool that allows files, printers, and various services to be shared between Linux and Windows clients. In this tutorial, we will guide you through the installation process of Samba on Debian.

Prerequisites

Step 1 - Update the system package list

Use the following command to update the package list of your system:

sudo apt update

Step 2 - Install Samba

To install Samba, execute the following command:

sudo apt install samba

Step 3 - Configure the Samba service

To configure the Samba service, we need to edit the Samba configuration file. Open the /etc/samba/smb.conf file with your preferred text editor.

sudo nano /etc/samba/smb.conf

Configure Share directory

The following section defines the Samba share where files will be hosted. You can use an existing directory or create a new share directory. In this example, we'll create a new directory:

[share]
    path = /srv/samba/share
    read only = no
    browsable = yes

Enable the user and set up a password

Now, we need to create a new user account for Samba and set up the password.

sudo smbpasswd -a username

Replace the "username" with your preferred username.

Allow Samba in Firewall

By default, Firewall is enabled on Debian, so you need to allow Samba services through it. Use the commands below to add the Firewalld rules:

sudo ufw allow samba

Restart the Samba service

After configuring everything, restart the Samba service to apply the changes.

sudo systemctl restart smbd

Step 4 - Accessing Samba shares from Windows

Open the File Explorer on your Windows machine and go to "This PC."

In the address bar, type the IP address of the Debian machine (\\<IP address>).

Enter your Samba credentials to access the shared folder, like:

Username: <username>

Password: <password>

Now, you can access your Samba shares from your Windows machine.

Conclusion

Samba is a powerful tool for sharing files and printers between Linux and Windows machines. In this tutorial, we covered how to install and configure Samba on Debian.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!