What is the usage of exportfs in Linux?
The exportfs command in Linux is used to share file systems over a network. By using the exportfs command, one can share one or more directories of a local file system with local or remote clients. The syntax is as follows:
Export file system directories using specified options.
Common options include:
- Export all locally mounted file systems.
- -o options: specify mounting options, such as rw (read-write) or ro (read-only).
- -U: Unmount the shared directory.
For example, to share the directory /home/share with a remote client, you can use the following command:
Make the directory /home/share readable and writeable by others.
This will allow other machines to access the /home/share directory using the NFS (Network File System) protocol and have both read and write permissions. On remote clients, the shared directory can be mounted using the mount command, or the showmount command can be used to view directories that are already shared.
It’s important to note that the exportfs command can only be used on the NFS server and not on the client. Additionally, the shared directory needs to be configured in the /etc/exports file, and after configuring it, you need to use the exportfs command to reload the configuration file for it to take effect.