File Sharing over Network

File sharing is probably one of the most useful thing that can be accomplished by joining multiple computers over a network. There are countless ways to share files between computers, including over the Internet, over the local network or even copying files via a physical storage media such as a USB flash drive.

This article will focus on file sharing over local network (LAN). Linux operating system would be assumed, but the Windows counterpart will also be discussed wherever available. In fact most of the methods discussed will work on all computers regardless of the operating system, and even on mobile devices.

Before we proceed, there are a few questions to be answered—

First questions

Am I on a local network?

  1. Do you have a router?
  2. Do you have wired Internet connection?
  3. Are your computers connected via Ethernet?

If answer to any of the above question is yes, then congratulations, you probably already have a local network.

What if I'm not on a local network?

Then this article won't be of much help to you. But you want to get the benefits of file sharing over LAN there are a few ways to get a local network—

  • Get a router. The easiest way to get LAN. But it's costly too.
  • Get an Ethernet switch.
  • Create an ad-hoc wi-fi connection. Probably the only free option provided you have wi-fi in your computers.
  • Get an Ethernet cross-over cable.

Please note that the focus of this article is not on building a local network, so the above options won't be described in detail here.

Pros and Cons of LAN file sharing


  1. LAN file sharing is typically much faster than over the Internet sharing like email or cloud services such as Dropbox, Google docs etc. Since the Internet speed is limited by the Internet service provider, sharing large files over the Internet is often impractical. But the local network has no such restriction and has a much higher speed, making it ideal for large file sharing.
  2. In case of LAN file sharing the files move directly from one computer to another. But Cloud services require third party support, who may impose some added restrictions. It also implies that your data will be stored in a third party server.
  3. The physical methods such as USB flash drives or USB hard drives work great for large files. But they require physical access to both the computers, which may not be possible. It's also cumbersome and not very tech savvy to copy the files back and forth multiple times between devices.


  1. You need to have a working local area network.
  2. File sharing over LAN may require some setup.

Some basic concept about LAN file sharing

File sharing over LAN requires one computer to act as Server and the others as client
Basic model of LAN file sharing

LAN file sharing depends on the Client-Server model as shown in the above picture.

The server can be considered as a passive participant in the file-sharing in the viewpoint of a user. The server holds the files and allows the clients to connect. Whereas the clients connect to the server and actively performs the file exchange. When a client gets a file from the server its called downloading, and when a client sends a file to the server it's called uploading.

If you are trying to transfer files between two computers, choose any one of them to be the server and the other to be the client. But in some cases it may be necessary to make both of them servers (when file upload is not possible), in which case both of them will act as clients as well.

Almost all the setup required for a successful file sharing is required on the server. The clients rarely require any special setup.

Things you need to know before proceeding any further

There are some basic things you need before you can proceed with any of the methods described below—

  1. You need to know the Server's IP address.

    If the server is running Linux—

    1. Open a terminal at the server.
    2. Enter ifconfig
    3. The IP address will appear as inet addr:xxx-xxx-xxx-xxx (x represents number) under the specific interface (eg. eth0 for Ethernet, wlan0 for wi-fi etc.).
    4. Write down the IP address. It will be required while connecting the client to the server.

    If the server is running Windows—

    1. On the server Start menu → Search box → type cmd.exe → Enter.
    2. Type ipconfig at the prompt and press enter.
    3. The ip address will appear as IPv4 Address....: (x represents number). Please note the number. We are going to need it very soon.
  2. You need Port Forwarding if you are using a router.

    If both of your computer is connected to the same router, you can skip this step. But if your server computer is separated from the client computer by an intermediate router, you need to forward some specific ports.

    Every router has different methods for forwarding ports, so please refer to the manufacturer's manual. The most general steps are described here—

    1. Connect your server to the router.
    2. Go to the administration web page (e.g. and Enter user-name and password.
    3. Go to the section resembling Forwarding/Virtual servers and add the rule for the port forwarding.

      So if you want to forward port 8080, add a rule that forwards all incoming connection to port 8080 of the router to the port 8080 of the server computer's IP address.

    Common ports associated with different methods are mentioned with their description.

  3. You need to modify your Firewall to allow access to specific port.

    The procedure depends on the firewall program you are using. You need to allow the sharing port to be accessible through the firewall. So if you're using port 8080 for sharing files you need to allow incoming connections to port 8080 on the server computer.

    E.g. if you are on a Ubuntu based system and will be using port 8080 you can open the port by doing sudo ufw allow 8080.

Options available for LAN file sharing

Following are the most common options for file sharing.

  1. HTTP
  2. FTP
  3. SSH
  4. NFS/Samba
  5. BitTorrent

File sharing over HTTP

What do you need?

  1. On server computer you need to set-up an HTTP server.
  2. Absolutely no set-up is required on the client computer.

How to setup an HTTP server

On Linux

  1. Python: In most Linux systems Python is installed by default, so you don't need to install anything for this method to work. Python has a module called SimpleHTTPServer that can be used to share a folder over the network. It's probably the easiest method described here.

    The steps are as follows—

    1. Open a terminal. Please note that most modern GUI based Linux distros allow to open a terminal directly from a specific folder. In that case the step 2 won't be necessary.
    2. Go to the directory you want to share. Type the command cd <directory-to-share>
    3. Type the command python -m SimpleHTTPServer or if you have python 3 you can do python3 -m http.server.
    4. When the file transfer is complete hit ctrl-c to terminate the connection.

    The default port for Python HTTP server is Port 8000

  2. NodeJS: NodeJS is based on server-side JavaScript. NodeJS http server is often claimed to be faster than Python HTTP server.

    Installing NodeJS takes a good amount of time and effort. But once installed it's as easy as the Python server to use.

    1. Install NodeJS. On Ubuntu based systems you can do sudo apt-get install nodejs
    2. On Ubuntu based systems you need to create a symlink in /usr/bin/ directory for NodeJS to work. Use sudo ln -s /usr/bin/nodejs /usr/bin/node
    3. Install npm. On Ubuntu based systems do sudo apt-get install npm
    4. Now install http-server globally. You can do npm install http-server -g.
    5. Once all the installations are finished, you can then share any folder just like the python way. Just open the folder in the terminal and type http-server. Once the file transfers are finished hit ctrl-c to terminate the server.

    The default port for NodeJS HTTP server is Port 8080

  3. Apache: This is a full fledged server program and more suitable for running a complete server than just file sharing. However you can use it for file sharing too if you wish.

    1. Install Apache. On Ubuntu based systems sudo apt-get install apache2.
    2. Apache serves the contents of the /var/www/html directory. So if you want to share a file or folder you'll have to copy it to that folder. You can also place links there but you'll have to make the necessary adjustments to file permissions to make them accessible to a client.

    The default port for Apache server is Port 80

On Windows

  1. HFS: HFS is a windows executable that allows easy sharing of files via HTTP.

    1. Download the HFS executable. A Google search should suffice to get the link.
    2. Run the executable. No installation is required.
    3. Drag and drop the files and folders you want to share on the program window.

    The default port for HFS is Port 80

  2. Apache: Apache is also available for windows as part of XAMPP or WAMP stack.

    1. Download and install XAMPP or WAMP.
    2. Copy the files and folders to the shared directory (depends on the stack and version you are using).

    The default port for Apache server is Port 80

How to share the files on client

No setup is required on the client side. But you need to know the server ip address. The steps to download the files are as follows—

  1. Open a Web Browser window.
  2. In the address bar type http://<server-ip-address>:<port-number>.

    The port number varies depending on the program running on the server. Most common port number associated with the programs have been mentioned above.

    So if the server's ip address is and it's running Python HTTP server for file sharing, you have to enter in the address bar of the client's web browser.

  3. You'll see a list of files shared on the server. Just click on them and download to the client.

Pros and Cons of file sharing over HTTP

  • Pros: Simple, fast, easy to use.

  • Cons: Insecure.

Please remember

As HTTP file sharing usually doesn't allow client to server transfer, you need to setup the server on both computers. You can then use both computers as clients to download files from each other.

File sharing over FTP

What do you need

  1. An FTP server on the server computer.
  2. Most file browser can act as an FTP client. But you can use a specialized FTP client if you want.

How to setup an FTP server

  1. Install an FTP server on the server computer.

    There is a huge number of FTP server softwares on all platforms to choose from. The most notable on Linux is vsftpd which stands for Very Secure FTP Daemon. Similarly there is a Filezilla FTP server for Windows, which can be downloaded and installed from their website.

    To install vsftpd on Ubuntu based system you can open a terminal and type sudo apt-get install vsftpd.

  2. Configure the FTP server. Configuring the server depends on the software and the version you are using. But most of the time the server will work perfectly with the default configuration.

    For vsftpd on Ubuntu based systems you need to edit the /etc/vsftpd.conf file. You can allow anonymous connection (disabled by default) by editing the line anonymous_enable=NO to anonymous_enable=YES. You need to restart the FTP server after changing the configuration file by typing sudo service vsftpd restart.

  3. Copy the files and folders to the FTP directory.

    It depends on the software used. For vsftpd the folder is /var/ftp/.

FTP server uses Port 21.

Share files on Client side

  1. If you have a specialized FTP client like Filezilla, you can use it to access the server. The host name is the server IP address. If anonymous login is allowed you can use the user-name anonymous and use whatever password you like.
  2. You can also simply use a file browser to access the files. In the file browser's address bar type ftp://<server-ip-address>.
  3. Web browsers can be used too. Type ftp://<server-ip-address> in the web browser's address bar and you can access the files.

Pros and Cons of FTP sharing

  • Pros: Supports download as well as upload. Provides basic user-name/password authentication.

  • Cons: Difficult to set-up. All passwords are transmitted in clear-text and can be intercepted, hence insecure.

File sharing over SSH

What do you need

  1. An SSH server.
  2. An SSH client. Most Linux distros are equipped with an SSH client by default. But for windows a special client is needed such as PuTTY.

How to setup an SSH server

  1. The most notable SSH server for Linux is the Openssh Server. On Ubuntu based systems you can use sudo apt-get install openssh-server to install it.
  2. You can configure the server by editing the file /etc/ssh/sshd_config. But the default configuration should work just fine. If you edit the configuration be sure to restart the SSH Server by doing sudo service ssh restart.
  3. Create a separate account on the computer that is to be used by the client.

Setup the client

On Linux systems you can copy files by using scp. Alternatively most Linux distro has file browsers capable of handling SSH connection. In the file browser's address bar type ssh://<user-name>@<server-ip-address> and enter the password when prompted.

On windows you need to install PuTTY in order to access an SSH server.

Pros and Cons of SSH file sharing

  • Pros: Most secure among the file sharing options described here. Passwords are encrypted and can't be intercepted. Both file download and upload are possible. Besides file sharing also supports services like remote shell access, ssh tunnel etc.

  • Cons: Requires user account on the server computer, so anonymous file transfer not possible. Requires time and effort to setup. Requires special client.

NFS/Samba file sharing

NFS and Samba are folder sharing system. A folder from the host computer shared over NFS/Samba and the shared folder is mounted form a client computer. That way the contents of the folder can be used from both computers.

If all computers are running Linux then NFS is preferred. However if you need file sharing with Windows computers, you need to use Samba.

What do you need

  1. NFS server on Linux host / Samba server on Windows host
  2. NFS client / Samba client on the client computer. Most Linux distros come with NFS client.

How to setup the Server


  1. Install NFS server. On Ubuntu based systems sudo apt-get install nfs-kernel-server.
  2. Configure NFS server. You have to add the shared folder to the /etc/exports file.

    for example if you want to share a folder /home/username/shared, add the following to your /etc/exports

    /home/username/shared *(rw,sync,no_root_squash)

  3. Start NFS server. On Ubuntu sudo service nfs-kernel-server start


  1. Install Samba server. On Ubuntu based systems sudo apt-get install samba.
  2. Set a password for your username. sudo smbpasswd -a <username>.
  3. Configure Samba server. Edit the /etc/samba/smb.conf and add the following lines at the bottom (assuming the folder you want to share is shared in your home directory)—

    path = /home/<username>/shared
    valid users = <username>
    read only = no

  4. Restart samba. sudo service smbd restart

Setup the client


  1. Install NFS client. In Ubuntu based systems sudo apt-get install nfs-common
  2. Mount the shared directory. sudo mount <server-ip-address>:/home/username/shared <mount-point>


  1. Install samba client. In Ubuntu based systems sudo apt-get install smbclient
  2. Connect the shared folder. smbclient //<server-ip-address>/shared -U <username>

Pros and Cons of NFS/Samba File Sharing

  • Pros: Permanent file sharing between two systems. Can use the same home directory in multiple computers.

  • Cons: Requires extensive setup. Robust security is present. Requires additional complex setup to create secure connections.

Sharing files via BitTorrent

This is different from all other methods described above. Instead of a server client style, it follows a point-to-point file sharing.

What do you need

A BitTorrent client, e.g. μTorrent, Transmission, Deluge, KTorrent etc.

How to share a file

  1. Open the BitTorrent client.
  2. Create a new torrent file for the file you want to share. (File → New → select file or folder to share).
  3. Send the torrent file to everyone you want to share the large file with. To send the small torrent file you can use any of the above methods, or you can simply email the file.
  4. Keep seeding the file as long as people are downloading.

Pros and Cons of BitTorrent sharing

  • Pros: Easy, suitable for sharing large files with a lot of people.

  • Cons: Takes time to create torrent files every time you want to share something, and the torrent files need to be sent to everyone. Data transmission is insecure.

Which method to use

Depending on the scenario, one method or the other may be more suitable—

Quick sharing of files between two computers HTTP share is the best method. Because once setup is finished, it allows almost instantaneous sharing of files.
Secure transfer of sensitive files SSH is the way to go. It is currently one of the most secure way to transfer files.
Permanent shared directory NFS/Samba is useful for permanent sharing of directories between computers
Sharing large files with multiple computers BitTorrent is best when sharing files with multiple people.

Bonus fact

If you are using Linux you can share a file instantaneously with another computer by using the fabled netcat.

Suppose you are trying to send a file named file.txt from computer A (IP address to computer B.

  1. In a terminal on computer A type cat file.txt|nc -l 8000.
  2. In a terminal on computer B type nc 8000 >file.txt.



Copyright © 2012-2024 Dr. Agnibho Mondal