BCE-C712 Linux System Administration

0 of 74 lessons complete (0%)

Network Information System (NIS) and Network File System (NFS)

The exports File

You don’t have access to this lesson

Please register or sign in to access the course content.

The exports file is a configuration file used by the NFS (Network File System) server to specify which directories can be exported (shared) to remote clients and what level of access those clients have. It is located at /etc/exports on most Linux distributions.

The syntax of entries in the exports file is as follows:

<directory> <client>(<options>)

Here’s what each component means:

  • <directory>: This is the path of the directory you want to export. It can be a specific directory or a mounted file system.
  • <client>: This can be an IP address, hostname, or a wildcard (*) to specify which clients are allowed to access the exported directory.
  • <options>: These are comma-separated options that specify the level of access and other settings for the exported directory.

Here are some common options used in the exports file:

  • ro: Read-only access. Clients can only read from the exported directory.
  • rw: Read-write access. Clients can both read from and write to the exported directory.
  • no_root_squash: By default, NFS maps the root user to an anonymous user. This option disables that behavior, allowing the root user on the client to have root privileges on the shared files.
  • all_squash: Maps all client users to an anonymous user, even if they are the root user on the client.
  • sync: Ensures that changes are immediately written to the disk on the server, providing greater data integrity but potentially slower performance.

Here is an example exports file:

/home/user/documents /media/storage *(ro,sync)

In this example, the /home/user/documents directory is exported with read-write access to the client with IP address The /media/storage directory is exported to all clients with read-only access and synchronous writes.

After editing the exports file, you need to apply the changes by either restarting the NFS server or using the exportfs command:

sudo exportfs -a

Keep in mind that improper configuration of the exports file can lead to security vulnerabilities or unintended access to sensitive data. Always ensure that you understand the implications of the options you use and regularly review your NFS configuration for security best practices.