Easiest Way to Exclude NFS Mount Points in find Command
Today, I was told to remove a domain group from the active directory. However, there were files/directories owned by that group on most of the Linux servers. It was my task to find all those files/directories and change their group.
I started using below command to list down the files/directories owned by group e.g indiagrp
$ sudo find / -group indiagrp
However, there were few nfs auto mounts configured on the servers which were delaying the search as the size of mount points was in TBs. I had to exclude those nfs mount points. I used the below command to exclude those automount points.
$ sudo find / -xautofs -group indiagrp
Here, -xautofs: Don’t descend directories on autofs filesystems.
As an alternative to this you can use below command to search all files/directories using below command provided there is only root i.e / mount point configured on the server.
$ sudo find / -xdev -group indiagrp
Here, -xdev: Don’t descend directories on other filesystems.
xdev exclude mount points other than provided in the find command. E.g using the above command it will exclude /var or /usr mount points if those are configured as separate mount points on the server.