How to use SMB Protocol In Linux
One other way of transferring files from Linux to Windows is by connecting both OS systems using the SMB (Server Message Block) protocol. SMB can be used both in Windows and Linux to initiate a connection to share and transfer files.
Step 1: Use/ Install Samba in Linux
Samba is an open-source software which provides clients with file and print services in a Windows-based network. This software supports connections between Windows systems and can be used to transfer files.
To install Samba, type the following commands in your Linux terminal.
sudo apt install samba -y
After successfully installing samba-client, check its status by typing the command:
systemctl status smbd
Step 2: Create a shared directory
When transferring files from Linux to Windows, create a shared directory which will be used by both Linux and Windows OS. Follow the command below to see how to do so.
mkdir <directory_of_your_choice>
Give administrative permission using the chmod command.
chmod 777 <directory_of_your_choice>
Note: There are several numbers in chmod which are used to give specific permissions. They are
- 777– everyone can read, write and edit (full access)
- 755– Owners can read, write and execute, and group users can read and edit the file.
- 644– Only owners can read, write and execute the files. The other people included by the owner can only view the file.
Step 3: Create a new user specifically for file-sharing
While sharing files, create a new user whose account will be used for the sharing/ transfer of files. The command for this is
useradd <username>
Step 4: Give an SMB password for the user
To facilitate SMB protocol under the user, you must create an SMB password by executing the command below
smbpasswd -a <username>
Then type out the password in the terminal.
Step 5: Edit the config file in samba using any editor (or nano)
Type out the command below
sudo nano /etc/samba/smb.conf
After opening the file, scroll to the bottom of the file and add the following lines.
path = <directory_of_your_choice> valid users = <username> read only = no browsable = yes public = yes writable = yes browsable = yes
Save and exit the file, then check if everything was edited and saved successfully by running the following command.
testparm
Step 6: Find the IP address of your Linux System
Using ifconfig, find the IP address of your Linux system.
ifconfig wlo1
Your IP address will be shown below:
Step 7: Connect to the network from the Windows side
Launch the “Run” program by pressing the “Windows button” and “R”. Then type the IP address of the Linux system you got from the previous step. Type the IP address with two slashes before it.
This will open the Linux-shared folders. Now you can view it and transfer files in between.
How To Transfer File From Linux To Windows?
There are many reasons why many people need to transfer files across Linux to Windows OS, be it for work, or for platform compatibility. Rest assured, this kind of file transfer is relatively effortless to do so. It is well-known that transferring files from Linux to Windows is scary and vice versa.
In this article, we’ll go through how to send files across Linux to Windows and vice versa easily.
Table of Content
- Method 1: Using SSH Transfer Protocol with PuTTy
- Method 2: Using FTP with FileZilla or Shared Network Folders
- Method 3: Using SMB Protocol