Sub topic 1
How network file sharing works
Network file sharing lets a client computer access files stored on a server through a network. The server owns the shared directory and runs a file-sharing service. The client connects through a protocol, which is a set of rules for requesting files, directories, and metadata.
This chapter assumes you are comfortable with the Linux command line, users, groups, file permissions, basic TCP/IP networking, package installation, and systemctl.
Prerequisites
You should know how to:
- Read and edit a configuration file.
- Use
chmod,chown, and groups. - Identify a server by hostname or IP address.
- Distinguish a local path such as
/srv/projectsfrom a network path such as//fileserver/projects. - Mount and unmount a filesystem.
The client-server model
The server publishes an export or share. An export is a directory made available through NFS. A share is a directory made available through SMB, the protocol used by Samba.
The client connects to the server and sends operations such as “open this file” or “list this directory.” The server checks access rules and local filesystem permissions before returning data. A network mount then makes the remote directory appear in the client’s local directory tree.
SMB and NFS compared
SMB, also called CIFS, is common in Windows and mixed operating-system networks. Samba is the Linux software that implements SMB. SMB supports authenticated accounts, named shares, and features expected by Windows clients.
NFS, or Network File System, is common between Linux and other Unix-like systems. NFS usually relies on numeric user IDs and group IDs. The client and server must therefore agree about identity mapping, or use a service such as centralized identity management.
| Characteristic | SMB with Samba | NFS |
|---|---|---|
| Best fit | Windows or mixed networks | Linux and Unix-like networks |
| Main access model | Samba authentication plus filesystem permissions | Client identity plus filesystem permissions |
| Server configuration | Samba configuration and share definitions | `/etc/exports` and export rules |
| Typical modern version | SMB3 | NFSv4 |
The protocol does not replace Linux permissions. A request can fail because the service rejects the client, the share rules reject the user, or the underlying directory permissions reject the operation.
Choosing a protocol
Choose SMB when Windows compatibility, per-user share authentication, or Windows-oriented management matters. Choose NFS when Linux clients need a filesystem-style mount with low protocol overhead and identities are already managed consistently.
A server can provide both protocols, but avoid exporting the same writable directory through both unless you understand how each protocol handles locking, identities, and permissions.
Exercise
A Linux server must provide a project directory to Windows laptops and Linux workstations. Which protocol is usually the better starting point, and why?
Show answer
SMB through Samba is usually the better starting point because it provides Windows compatibility and authenticated share access. Linux clients can also use SMB mounts.