exportfs – Manages a list of NFS shared filesystems

The exportfs command is a Linux utility that is used to manage the list of Network File System (NFS) shared filesystems in a Linux system. NFS is a distributed file system protocol that allows a user on a client computer to access files over a network as if those files were on the local computer. The exportfs command is used to specify which directories on the server are shared with clients and to configure how they are accessed.

Overview

To use the exportfs command, you must have root privileges. The basic syntax for the command is:

exportfs [options] [directories]

The exportfs command can be used to add, modify, or remove NFS shared filesystems. To add a new shared filesystem, you need to specify the directory that you want to share and the options that you want to use. For example, to share the directory /data with read-only access, you would use the following command:

exportfs -ro /data

To modify an existing shared filesystem, you can use the same command but with different options. For example, to change the access to read-write, you would use the following command:

exportfs -rw /data

To remove a shared filesystem, you can use the -u option followed by the directory that you want to remove. For example, to remove the /data directory from the list of shared filesystems, you would use the following command:

exportfs -u /data

You can also use the exportfs command to display the current list of shared filesystems by using the -v option. For example:

exportfs -v

This will display a list of all the directories that are currently shared, along with their access options.

Options

The following table lists the available options for the exportfs command:

Option Description
-a Export all directories listed in /etc/exports
-u Unexport a directory
-o Specify export options
-r Reexport all directories listed in /etc/exports
-v Verbose mode (display current list of shared filesystems)
-h Display help message

Troubleshooting Tips

Here are some troubleshooting tips for common issues with the exportfs command:

  • If you are having trouble accessing a shared filesystem from a client computer, make sure that the directory is listed in the /etc/exports file on the server and that the options are set correctly.
  • If you are having trouble exporting a directory, make sure that the directory exists and that you have permission to access it.
  • If you are having trouble with NFS in general, make sure that the NFS service is running on both the server and the client computers.

Notes

  • The exportfs command is typically used in conjunction with the /etc/exports file, which lists the directories that are shared and the options that are used.
  • When you modify the /etc/exports file, you must run the exportfs command to update the list of shared filesystems.
  • The exportfs command only exports directories that are listed in the /etc/exports file. If you want to share a directory that is not listed in the file, you must add it to the file first.