Linux File Sharing for Windows PC or VM with using SAMBA

The problem: The files/folders are needed to be shared with another PC or VM and we don’t want to use flash drive to move them.

Solution: Install Samba.

Installation of Samba

The following terminal commands will install the samba to the debian based linux distro. Here, it is ubuntu 20.04.

$ sudo apt install samba

After the installation process, share file need to be set. Some people define the share file just under the root. But, i prefer to share a folder in my mechanical disk which is already exist. I have arranged the disk auto-mounted by using disks.

Figure 1: Disks: Mount at System Startup

Create a folder or use existing folder to share. Check the folder privileges with
ls –l and if the folder privileges are root, define the folder for your username.

Figure 2. Folder privileges

I will share the Files folder here. Read and write privileges are already defined and it is defined to the users. Not root. I don’t need to change anything here. But, If your folder has different privileges, you can define that with the following commands.

$ ls -l
$ sudo chown username:username folder/

The folder will be on in the LAN but still we want it secure. So, we need to define a password for samba connection.

$ sudo smbpasswd -a username
Figure 3: Samba Password Settings

At the final step, the folder which is shared, will be defined into configuration file of samba. Use your favorite editor. vim, gedit, nano whatever you like.

$ sudo nano /etc/samba/smb.conf

NOTE: Check your windows machine and be sure that computer workgroup is WORKGROUP. If it is not, you need to edit that line in the configuration file which is given below.

Figure 4: workgroup info in smb.conf

The requirement settings are given below. To complete samba istallation on linux side, add the following codes to very end of the configuration file. [change folder path and user respect to yours]

Figure 5. Samba Configuration

Windows Connection for Share Files

Right Click in Computer and choose Add Network Location as seen in Figure 5 below.

Figure 6. Samba arrangements in Windows.

The usual installation in windows is next next and next. And, the same principle is valid here too. just arrange the path as your local ip and sharedname

\\localipoflinux\sharedname
Figure 7. Arrangement of Network Location

After the process, you need to enter your username and password which is created before.

Figure 8. Enter The Samba Pass

Now, It is ready to use it.

Figure 7. The Final Result

Leave a Reply