1. Install Samba Service
sudo apt update
sudo apt install samba samba-common smbclient # Install core packages
2. Configure Samba Service
Start and set the service to launch on boot:
sudo systemctl start smbd nmbd # Start smbd and nmbd services
sudo systemctl enable smbd nmbd # Set to launch on boot
Create a shared directory and set permissions:
sudo mkdir /shared_folder # Create shared directory
sudo chmod 777 /shared_folder # Grant full read/write permissions (refine permissions for production)
Add Samba user and password:
sudo smbpasswd -a your_username # Add system user to Samba (password required)
Edit Samba configuration file:
sudo nano /etc/samba/smb.conf
Add the following content at the end of the file:
[Shared]
path = /shared_folder
valid users = your_username
browseable = yes
writable = yes
guest ok = no # Disable anonymous access
create mask = 0777
directory mask = 0777
Restart the service to apply changes:
sudo systemctl restart smbd nmbd
3. Firewall Configuration (if enabled)
sudo ufw allow samba # Allow Samba through the firewall
4. Client Access
Linux Client:
smbclient //server_IP/Shared -U your_username # Command line access
# Or mount to local directory:
sudo mount -t cifs //server_IP/Shared /mnt/samba_share -o username=your_username,password=your_password
Windows Client:
-
Open Explorer, enter
\\server_IPin the address bar, and enter Samba username and password to access. -
Or map as a network drive.