How to transfer files from Linux to Windows: The SMB network file-sharing protocol

How to transfer files from Linux to Windows: The SMB network file-sharing protocol

Share files from Linux to Windows

·

2 min read

The SMB (Server Message Block) protocol is a widely used network file-sharing protocol that enables users to access and manage shared resources, such as files and printers. Although initially designed for Windows environments, SMB is also supported in Linux operating systems and can transfer files between Windows and Linux computers. This article will explore how to transfer files from a Linux machine to a Windows machine using the SMB protocol.

Install Samba on Linux

Samba is an open-source software suite that provides file and print services to SMB/CIFS clients. It allows Linux computers to participate in a Windows-based network and supports accessing and sharing files and printers with Windows computers. Samba implements the SMB/CIFS protocol and can create file and printer shares on a Linux machine that can be accessed from Windows computers and access Windows files and printer shares from a Linux machine. This way, Samba enables seamless file and printer sharing between Windows and Linux computers in a mixed-operating system environment.

Install samba:

sudo apt install samba -y

On successful installation, check the smbd status

systemctl status smbd

Replace wamaitha with your computer username and change paths to suite your needs.

We want to share movies from Linux to Windows. Create a folder that will be the shared folder.

mkdir /media/wamaitha/data/movies

Give full permission to the folder.

chmod 777 /media/wamaitha/data/MOVIES

Create a user that will be associated with the file sharing:

 useradd sambauser

Create an smb password for this user

smbpasswd -a sambauser

Edit the samba config file using nano or any editor of your choice

nano /etc/samba/smb.conf

Scroll to the bottom of the config file and add the following:

[Movies]
path = /media/wamaitha/data/MOVIES
valid users = sambauser
read only = no
browsable = yes
public = yes
writable = yes
browsable = yes

Save the file and check if everything was correctly configured using the following command:

testparm

Check your IP address on the Linux machine using ifconfig:

ifconfig wlo1

On the output, the IP address is shown below:

Connecting on windows

On windows launch run by pressing the windows logo + R .

Type the IP address of the Linux machine from the ipconfig output with two slashes.

\\192.168.0.101

This will open the Linux-shared folders.

You can now access the files in the Movies folder on Linux from windows.

Resources:

https://www.samba.org/samba/what_is_samba.html