File sharing between Windows and Linux

File sharing refers to the idea of distributing or providing the right to read, write, modify, delete, etc. to the next person, who is not the owner of the resources. This is widely practiced inside the network, where one computer can share the files and folders to the next computers. Here I will discuss the different method of file sharing between two giant operating systems, windows and Linux. It is pretty simple to share the files between the same OS but within two differently complete OS, it is necessary to configure some steps. Let’s start our discussion from Linux. This section will provide the hint to share the Linux file in the windows.

File sharing is the practice of distributing or providing access to digital media, such as computer programs, multimedia (audio, images and video), documents or electronic books. File sharing may be achieved in a number of ways. Common methods of storage, transmission and dispersion include manual sharing utilizingremovable media, centralized servers on computer networks, World Wide Web-based hyperlinked documents, and the use of distributed peer-to-peernetworking. -Wikipedia

In Linux, command line is popular to install any apps or do the administrative tasks. So, let’s start from the command line. There are different options you can use to get the terminal. If you have some problem going to the terminal, you have to see this LINK before going further. So, assuming you have some knowledge, we will go further. First, install SAMBA using following code

sudo apt-get install SAMBA

SAMBA is the software, that provides the file and print service for various windows clients and can also integrate with a windows domain.  After successful installation of SAMBA, the credentials are set up which are used to access the shared folders using following commands.

smbpasswd -a username

Then it will ask for the password.

Then make a directory using mkdir command and give the name. Name and location can be anything and anywhere. For example,

mkdir /home/user/Desktop/shareme

Now using any editor file, you have to configure the smb.conf file from location /etc/samba/smb.conf

I prefer to use vim as an editor, but you can use nano, geany, gedit or any others.  Then add these lines at the end of that file.

[<folder_name>]
path = /home/<user_name>/<folder_name>
available = yes
valid users = <user_name>
read only = no
browsable = yes
public = yes
writable = yes

Replace folder_name with the name of your folder that you decide to share. Path is the location of the folder, for example can be

path = /home/user/Desktop/shareme

and <user_name> is the user, who has the right to access that folders. This is the same user, we configured in  smbpasswd -a username then save the file and restart the SMB service using

sudo service smbd restart

Then move to a windows machine, to access this shared file. Create a new shortcut and provide the following format

\\IP-address\share-folder-name

where IP-address is the IP of your Linux machine and folder name is the folder which you shared.

For example, assuming IP 192.168.4.10 and share folder name is SHARE, then \\192.168.4.10\SHARE

The above-mentioned idea was to access the Linux file from windows. Now we will move to the next post, where Linux will be used to access the windows shared folder. Before going forward, make yourself sure that network discovery is turn on and file and printer sharing is enabled. You can change this by going to Network and Sharing Center > change advanced sharing settings.

Then, it is time to go to the folder location, that we need to share.

Right click on the folder you’d like to share, click properties.

Goto sharing tab and advanced sharing.

Sharing in windows

Then put a tick mark on share this folder. Now, the folder is shared but still we don’t want everyone to have complete access on that folder. So, we set up the permission to define the privilege for users. For example, if we want to give only READ permission to everyone, then this can be mentioned here.

Permission in File Sharing

Now, we need some package in Linux to access the shared folder from Linux.

We need cifs-utils package initially, which can be installed by going to

sudo apt-get install cifs-utils

This command must be executed with root or other users who have root privileges. Then create the directory, for example,/Desktop/shared-folder

Using the following command, the folder is mounted for sharing.

sudo mount.cifs //WIndowsPC-name/Share-folder /home/test/Desktop/shared-folder -o user=IAMUSER

Then you need a password for both machines. Firstly, it will ask for the Linux password and secondly for the windows password.

Enjoy your sharing!!!

mm

Anup Chhetri

IT system administrator

You may also like...

error: Content is protected !!