samba
shared directory over the LAN
samba
Introduction
To share a directory over the LAN on Ubuntu, the most common and user-friendly method is to use Samba, which allows you to share folders with Windows and other Linux systems easily. Here’s a simple step-by-step guide:
🛠️ Step-by-Step: Share a Directory on LAN (Ubuntu with Samba)
Install Samba
Open your terminal and run:
1
2
sudo apt update
sudo apt install samba
Choose a Directory to Share
For example, if you want to share your ~/Shared folder:
1
mkdir -p ~/Shared
Make sure your user owns the folder:
1
sudo chown $USER:$USER ~/Shared
Backup Samba Config File
1
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bk
Add Samba Config File
Open the Samba configuration file:
1
sudo nano /etc/samba/smb.conf
Scroll to the bottom and add this block:
1
2
3
4
5
6
7
[SharedFolder]
path = /home/YOUR_USERNAME/Shared
browseable = yes
writable = yes
guest ok = yes
read only = no
force user = YOUR_USERNAME
Replace YOUR_USERNAME
with your actual username.
Set Samba Password (Optional but recommended)
You can add your user to Samba with:
1
sudo smbpasswd -a $USER
Restart Samba
To apply the changes:
1
sudo systemctl restart smbd
Allow Samba Through the Firewall (if enabled)
1
sudo ufw allow samba
🔗 Access the Shared Folder from Another Device
On Windows, open \\YOUR_UBUNTU_IP\SharedFolder
in File Explorer.
On another Linux, use:
1
nautilus smb://YOUR_UBUNTU_IP/SharedFolder
Replace YOUR_UBUNTU_IP
with the local IP of your Ubuntu system (you can find it with ip a
).
This post is licensed under
CC BY 4.0
by the author.