Operations 15 min read

Linux File Sharing Deep Dive: 7 Methods from Installation to Real‑World Use

This guide walks through seven Linux file‑sharing solutions—NFS, Samba, FTP, SFTP, WebDAV, rsync, and iSCSI—detailing installation, configuration, usage commands, common pitfalls, and when to choose each method for different scenarios.

AI Agent Super App
AI Agent Super App
AI Agent Super App
Linux File Sharing Deep Dive: 7 Methods from Installation to Real‑World Use

NFS: The Simplest Linux‑to‑Linux Share

Install nfs-utils (yum or apt), create a shared directory, and add an export rule in /etc/exports such as /data/shared 192.168.1.0/24(rw,sync,no_root_squash). The rule defines the path, allowed client subnet, read/write permission, sync mode, and root‑squash behavior. Enable and start the service with systemctl enable --now nfs-server, then verify with showmount -e localhost. On the client, install nfs-utils, create a mount point, and mount using mount -t nfs 192.168.1.100:/data/shared /mnt/nfs. Add the same line to /etc/fstab for automatic mounting.

Samba: Seamless Linux‑Windows Interoperability

Install samba and samba-client, create a shared directory, and set permissions. Edit /etc/samba/smb.conf to add a share definition with guest ok = no and a specific valid users list. Create a system user (e.g., alice) and set a Samba password with smbpasswd -a alice. Start the services via systemctl enable --now smb nmb and open the Samba ports in the firewall. Windows clients can access the share via \192.168.1.100\\share or map it with net use. A SELinux note warns to run setsebool -P samba_export_all_rw on if access fails.

FTP: Classic but Insecure

Install vsftpd, edit /etc/vsftpd/vsftpd.conf to disable anonymous login ( anonymous_enable=NO), chroot local users ( chroot_local_user=YES), and allow writable chroot ( allow_writeable_chroot=YES). Create a dedicated FTP user with useradd -s /sbin/nologin ftpuser and set a password. Enable the daemon with systemctl enable --now vsftpd. Clients can connect via the command‑line ftp or GUI tools like FileZilla. The article advises using SFTP instead for security.

SFTP: Secure File Transfer Over SSH

No extra packages are required if OpenSSH is present. Connect with sftp [email protected] and use familiar commands: put, get, ls, exit. To restrict a user to SFTP only, add a Match Group sftponly block in /etc/ssh/sshd_config that sets ChrootDirectory, forces the internal SFTP command, and disables X11 and TCP forwarding. Create the group and user, set the correct ownership (root:root on the chroot directory, 755 permissions), create a writable subdirectory, and restart SSH.

WebDAV: HTTP‑Based File Sharing

Configure Nginx with the --with-http_dav_module flag. In the server block, define a location /webdav/ that sets alias /data/webdav/, enables DAV methods, and configures basic authentication with an .htpasswd file. Clients can mount the share on Linux with mount -t davfs http://server/webdav/ /mnt/webdav/, on Windows via “Add a network location”, and on macOS through Finder’s “Connect to Server”. The article stresses using HTTPS in production.

rsync: Efficient Incremental Synchronization

Use rsync -avz --delete /data/webapp/ /backup/webapp/ for local backups, rsync -avz -e ssh /data/ user@backup-server:/data/backup/ for remote sync, and rsync -avz user@server:/data/reports/ /local/reports/ to pull data. Key options: -a (archive), -v (verbose), -z (compress), --delete (mirror delete), and -e ssh (encrypted transport). A common pitfall is the trailing slash: /data/webapp/ syncs contents, while /data/webapp syncs the directory itself. Schedule with cron, e.g.,

0 2 * * * rsync -avz --delete /data/ [email protected]:/backup/

.

iSCSI: Block‑Level Remote Disk

Install targetcli on the server, create a backstore block device, define an iSCSI target with a unique IQN (e.g., iqn.2026-01.com.example:server01), map a LUN, and set ACLs. On the client, install iscsi-initiator-utils, discover the target with iscsiadm -m discovery -t st -p 192.168.1.100, and log in with iscsiadm -m node -T iqn.2026-01.com.example:server01 -l. After login, the new block device appears (e.g., /dev/sdc), which can be formatted and mounted. The article warns against mounting the same iSCSI LUN on multiple hosts without a clustered filesystem.

Choosing the Right Method

The author summarizes the trade‑offs: NFS for Linux‑to‑Linux, Samba for Windows access, SFTP for quick encrypted transfers, rsync (with -e ssh) for encrypted incremental backups, WebDAV for firewall‑friendly HTTP access, iSCSI for block‑level storage, and FTP only for legacy compatibility. In everyday work, NFS plus SFTP cover most scenarios.

Final Thoughts

While file sharing sounds simple, production use involves many details—NFS no_root_squash settings, Samba SELinux policies, SFTP chroot permissions, rsync slash semantics, and iSCSI multi‑host considerations. The author shares these pitfalls to help readers avoid common mistakes.

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.

rsyncNFSiSCSISFTPFTPSambaWebDAV
AI Agent Super App
Written by

AI Agent Super App

AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning

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.