showmount Command in Linux



The showmount command in Linux is a useful utility for displaying information about NFS (Network File System) shares on a server. This command allows administrators to query an NFS server and view details like the exported file systems, the clients connected, and the directories accessible over the network. It’s particularly helpful when troubleshooting NFS-related issues or auditing the accessibility of shared resources within a network.

Table of Contents

Here is a comprehensive guide to the options available with the showmount command −

Installing showmount Command in Linux

To install the showmount command, you need to install the NFS utilities package, which includes showmount along with other NFS tools. Here’s how you can do it on different Linux distributions −

Ubuntu/Debian

sudo apt install nfs-common

Fedora

sudo dnf -y install nfs-utils

CentOS/RHEL

sudo yum -y install nfs-utils

Arch Linux

sudo pacman -S nfs-utils

Syntax of showmount Command

The basic syntax for using the showmount command is −

showmount [options] [hostname]

Where −

  • [options] − Flags to customize the behavior of the command.
  • [hostname] − Specifies the NFS server to query. If omitted, it defaults to the local machine.

showmount Command Options

Here are the commonly used options for the showmount command −

Option Description
-e, --exports Displays the list of all file systems exported by the NFS server.
-a, --all Shows both the exported file systems and the clients that are actively mounted on them.
-d, --directories Lists only the directories that are actively mounted by NFS clients.
--help Displays the help information for the command.
--version Displays the version information of the showmount command.

Examples of showmount Command in Linux

Here are some practical examples that demonstrate how to use the showmount command effectively −

  • Viewing Exported File Systems
  • Listing Connected Clients and Mounted Directories
  • Displaying Only Mounted Directories
  • Checking Local Exports
  • Displaying Help Information

Viewing Exported File Systems

To list all file systems exported by an NFS server, use −

sudo showmount -e hostname

Replace hostname with the name or IP address of the NFS server. If running the command on the local server, omit the hostname. The output will look something like this −

Viewing Exported File Systems Using showmount

This displays the directories that are shared (exported) and the clients allowed access.

Listing Connected Clients and Mounted Directories

If you want to see both the exported directories and the clients actively mounting them, use −

sudo showmount -a hostname

An example output might be −

Listing Connected Clients and Mounted Directories Using showmount

This shows the IP addresses of connected clients and the directories they are mounting.

Displaying Only Mounted Directories

To view only the directories that are actively mounted by NFS clients, use −

sudo showmount -d hostname

The output will list the directories being used, such as −

Displaying Only Mounted Directories Using showmount

Checking Local Exports

If you want to check what file systems are exported on the local server, simply run −

sudo showmount -e
Checking Local Exports Using showmount

This is particularly useful for determining which shared directories are currently in use.

Displaying Help Information

If you’re unsure about the available options or need guidance, use −

sudo showmount -h

This will output a list of available options and brief descriptions for using the command.

Displaying Help Information Using showmount

Conclusion

The showmount command is an essential tool for administrators managing NFS shares in Linux environments. By using its various options, you can efficiently view export lists, monitor connected clients, and troubleshoot access issues with shared directories.

Mastering the showmount utility can greatly simplify the management of networked file systems and ensure secure, efficient resource sharing.

Advertisements