“mountpoint” is a command-line utility used in Linux and Unix-like systems to test if a directory is a mountpoint, i.e. if it is the location where a filesystem is mounted. A mountpoint is a directory on the file system where a storage device or a remote file system is mounted. When a storage device or a remote file system is mounted, its files and directories are made available at the mountpoint, and can be accessed just like any other files and directories on the file system.
The “mountpoint” command is used to test if a directory is a mountpoint by checking if it is the root of a mounted file system. If the directory is a mountpoint, the “mountpoint” command returns an exit status of 0, and returns an exit status of non-zero otherwise.
For example, you can use the “mountpoint” command to test if the directory “/mnt/data” is a mountpoint, by running the following command:
# mountpoint /mnt/data
If “/mnt/data” is a mountpoint, the command will return an exit status of 0, and you can access the files and directories of the mounted file system at “/mnt/data”. If “/mnt/data” is not a mountpoint, the command will return an exit status of non-zero, and you will not be able to access the files and directories of a mounted file system at “/mnt/data”.
The “mountpoint” command is useful for shell scripts and other programs that need to determine if a directory is a mountpoint, and to take appropriate actions based on this information.
mountpoint Command Examples
1. Check if a directory is a mountpoint:
# mountpoint path/to/directory
2. Check if a directory is a mountpoint without showing any output:
# mountpoint -q path/to/directory
3. Show major/minor numbers of a mountpoint’s filesystem:
# mountpoint --fs-devno path/to/directory