Operations 9 min read

Master Linux File Sharing: SCP, Rsync, HTTP Server, NFS & Samba Explained

This guide walks you through multiple Linux file‑sharing techniques—including SCP, Rsync, a simple Python HTTP server, NFS, and Samba—detailing when to use each method, the required commands, configuration steps, and practical tips for reliable cross‑machine transfers.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux File Sharing: SCP, Rsync, HTTP Server, NFS & Samba Explained

1. Overview of File Sharing

When you need to move data between computers on the same network, a USB drive can work but is often inconvenient; network‑based file sharing provides a faster, more flexible solution. Below are several common Linux tools for copying files or synchronizing directories across hosts.

2. Using scp

scp

(secure copy) works like cp but transfers files over SSH, inheriting SSH authentication and encryption.

Copy from local to remote

$ scp myfile.txt [email protected]:/remote/directory

Copy from remote to local

$ scp [email protected]:/remote/directory/myfile.txt /local/directory

Copy an entire directory

$ scp -r mydir [email protected]:/remote/directory

3. Using rsync

rsync

also transfers files over SSH but uses a delta‑algorithm to send only changed parts, which saves bandwidth and resumes interrupted transfers.

Common options:

V – verbose output

r – recursive (process directories)

h – human‑readable numbers

z – compress data during transfer

Sync two local directories

$ rsync -zvr /local/directory/one /local/directory/two

Copy from remote to local

$ rsync /local/directory [email protected]:/remote/directory

Copy from local to remote

$ rsync [email protected]:/remote/directory /local/directory

4. Simple HTTP Server (Python)

Python can quickly expose a directory via HTTP, useful for ad‑hoc sharing. $ python -m SimpleHTTPServer Access the share from another machine using http://IP_ADDRESS:8000 or, on the same host, http://localhost:8000.

5. NFS (Network File System)

NFS is the standard Linux network file‑sharing protocol, allowing a server to export directories that clients can mount.

Start NFS client and mount a share

$ sudo service nfsclient start
$ sudo mount server:/directory /mount_directory

Automatic mounting For persistent mounts, edit /etc/fstab . If the server is unavailable at boot, the mount can delay or fail; using an automounter avoids this problem.

6. Samba (CIFS/SMB)

Samba implements the Windows SMB/CIFS protocol on Linux, enabling file and printer sharing with Windows machines.

Creating a Samba Share

Install Samba $ sudo apt install samba Edit /etc/samba/smb.conf to define the shared path and permissions.

Set a Samba password for a user $ sudo smbpasswd -a [username] Create the directory to share $ mkdir /my/directory/to/share Restart the Samba service

$ sudo service smbd restart

Accessing the Share

From Windows, use \\HOST\sharename in the Run dialog. From Linux, you can mount the share with:

$ sudo mount -t cifs servername:directory /mountpoint -o user=username,pass=password

Alternatively, the smbclient command line tool lets you browse and transfer files:

$ smbclient //HOST/directory -U user

Conclusion

Choosing the appropriate file‑sharing method for your workflow can dramatically improve efficiency and reduce friction when moving data between machines.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxNFSfile sharingSamba
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.