The Memory Bank

...for memory blanks

Site Tools


debian_based

Sharing files between Linux and Windows systems can sometimes feel like navigating a maze—but it doesn't have to be. With Samba, a powerful and flexible open-source implementation of the SMB/CIFS protocol, you can easily turn your Ubuntu machine into a file-sharing server that plays nicely with Windows, macOS, and other Linux machines.

Here’s a simple step-by-step guide to help you set up a Samba File Server in Ubuntu Linux. Let’s dive in! 🔧📡

🛠️ Step 1: Update Your System

Before we begin, it’s always a good idea to update your system packages to ensure compatibility and security.

sudo apt update && sudo apt upgrade -y

📦 Step 2: Install Samba

Samba doesn’t come pre-installed on Ubuntu, so you’ll need to install it first.

sudo apt install samba -y

To verify the installation:

smbd –version

🗂️ Step 3: Create a Shared Directory

Let’s create a folder that we want to share with others on the network.

sudo mkdir -p /srv/samba/shared

Now change the permissions so everyone can access it (or adjust as needed for security):

sudo chown nobody:nogroup /srv/samba/shared

sudo chmod 0775 /srv/samba/shared

📝 Step 4: Configure Samba

Open the Samba configuration file:

sudo nano /etc/samba/smb.conf

Scroll to the bottom and add this block:

[Shared] path = /srv/samba/shared browseable = yes read only = no guest ok = yes

This config allows guest users to access the shared folder without a password. For private sharing, you’ll need to set up Samba users (explained in the next step).

Save and close the file (CTRL + O, then CTRL + X in nano).

🔐 Optional: Create Samba User Accounts

If you want a more secure setup (recommended for private networks), create a new user and set a Samba password:

sudo useradd sambauser

sudo smbpasswd -a sambauser

Then modify your config like this:

[Shared] path = /srv/samba/shared valid users = sambauser guest ok = no read only = no

🔄 Step 5: Restart Samba

To apply changes:

sudo systemctl restart smbd

To make sure it’s running properly:

sudo systemctl status smbd

🌐 Step 6: Access the Share

Now you're ready to access the shared folder from other devices.

🔵 From Windows:

1. Press Win + R, type \\<Ubuntu-IP-Address>\Shared, and hit Enter.

2. Use credentials if authentication is required.

🟣 From Another Linux Machine:

smbclient 192.168.x.x/Shared -U sambauser Or mount it directly: sudo mount -t cifs 192.168.x.x/Shared /mnt -o user=sambauser

🚧 Troubleshooting Tips

1. 🧱 Firewall Issues: Make sure ports 137–139 and 445 are open on your Ubuntu firewall.

sudo ufw allow Samba

2. 🕵️‍♂️ Check Logs: If something goes wrong, check logs at /var/log/samba/.

✅ Wrapping Up

Setting up a Samba server on Ubuntu is a great way to create a seamless file-sharing environment across different platforms. Whether you're building a home network or a lightweight file server for your office, Samba is versatile, powerful, and relatively easy to configure.

debian_based.txt · Last modified: by 127.0.0.1