Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX Training Courses

Section 20.
File sharing

"A stateless protocol is one where each transaction is handled separately; the server doesn’t need to keep information about what clients have done previously. Being stateless allows an NFS server to reboot while clients are making requests and, once it returns to service, continue serving files to clients as if nothing had happened."

Zwicky, Cooper and Chapman - building Internet Firewalls, 2nd Edition.

20. File sharing in Linux.

The two most common tools for sharing files between networked hosts (Windows, Linux, UNIX, Apple and others) are NFS and Samba (CIFS/SMB).

20.1. Network File System NFS.

NFS, the Network File System was originally developed by Sun MicroSystems in 1984.

The current version of NFS is v4. Version 4 is the first to be developed by the Internet Engineering Task Force (INETF) after the handover from Sun MicroSystems. NFS v4 is much influenced by the Andrew Files System (AFS). It is stateful and includes mandatory security features. (The original NFS was designed to be "stateless" and was implemented entirely in UDP).

In order to run NFS we need remote procedure calls (RPC) and the NFS kernel server (nfs-kernel-server).

In order to use NFS services we need the nfs client (nfs-common).

Files can be directly exported from the command line but more usually the exports are set up in /etc/exports The command

exportfs -a

will export all the configured files and can be run at boot time.

Issuing the command without any flags will return a list of the currently exported files together with the access controls.

20.2. Exercise.

Install both the NFS server and client on your host.

Create a directory /export/home and transfer your home directory to this location.

Do an NFS mount of your own directory back to /home/<username>

Try mounting your colleagues home directories to your local host.

Read the section on using the automounter (autofs), and configure the automounter using /etc/auto.master and /etc/auto.home to automount your own and your colleagues home directories.

Read the manual pages on NFS security settings, limiting host access, exporting read only, root access etc. Modify your exports to reflect your understanding of these settings.

20.3. Sharing with Windows - Using Samba.

Samba is a free open source implementation of the Server Message Block (SMB), or Common Internet File System (CIFS), that is used by Microsoft Windows hosts.

Using the Samba server Linux files and printers can be made available to Windows desktop clients. The Samba client tools also make it possible to read and write Microsoft shares.

Samba can provide authentication services for windows hosts or can be configured to use Windows authentication servers.

20.4. Exercise.

Set up Samba on your local host.

Examine the file /etc/samba/smb.conf and remove the # characters that preceded the homes stanza.

Use the smbclient to access your own home directory and those of colleagues on other hosts in the training lab.

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.