top of page

Sharing files/folders between Windows and Linux using Samba

Sharing files between two Linux systems can be easily achieved using NFS (Network File System). But sharing files between Linux and Windows is slightly complex.


In this small experiment as shown in the figure, we have two Ubuntu Linux systems and one Windows 10 system.


1 On Samba server type

sudo apt-get install samba

2 Edit smb.conf file

sudo vi /etc/samba/smb.conf

3 In [Share Def] section add the following

[shared_folder]

path = /share

writable = yes

guest ok = yes

read only = no

create mask = 0777

directory mask = 0777

4 Add a samba user or use the already existing user

sudo passwd -a sambath

5 Restart Samba service

sudo service smbd restart

6 Configure Windows client to access the Samba share:. Open File Explorer on your Win system and type

\\192.168.0.154\share

7 You should now be able to access the shared folder on the Linux machine from your Windows system using Samba-based file sharing. Ensure that the Linux machine's firewall allows Samba traffic (TCP ports 137, 138, 139, and 445)

8 Configure Linux client to access the Samba share. On Linux Samba client, do the following:

9 sudo apt install smbclient

10 smbclient -L //hari

11 In the HOME directory create a file .samba_credentials and add the following. These are samba credentials created in STEP 4

username=sambath

password=******

domain=WORKGROUP

mkdir /share

sudo mount -t cifs -o rw,vers=3.0,credentials=/home/aijuser/.samba_credentials //IP-address/share /share

IP-address - IP of the Linux server on which Samba is installed


File Permissions: On the Samba server, grant appropriate file permissions so that Linux and Windows clients can read/write


References

https://phoenixnap.com/kb/ubuntu-samba

bottom of page