20 Advanced Linux Find Command Examples

Table of Contents

Linux find command is a powerful tool that can be used to locate and manage files and directories based on a wide range of search criteria. This means that we can provide it with a set of directories (or files) or filters, and it will apply appropriate actions to them and also to any directories and files within them.

This post covers 20 advanced Linx Find command examples. When using find, we would follow the syntax below.

find [options] [path] [expression]

  • options: This is optional. We can leave this out most of the time. We can read the manual page for all the options the find command has.
  • path: This is the directory we want to search.
  • expression: This is where we place our search criteria for what we want to find whether by name, or size etc.


Find Files with a specific file name in Linux

To list all files in the file system with a specified base file name, type: find / -name .profile -print

This command searches the entire file system and writes the complete path names of all files named .profile. The / (slash) instructs the find command to search the root directory and all of its subdirectories. In order not to waste time, it is best to limit the search by specifying the directories where we think the files might be.

Find Files with a specific permission in Linux

To list files that have a specific permission code in the current directory tree, type: find . -perm 0600 -print

This command lists the names of the files that have only owner-read and owner-write permission. The . (dot) instructs the find command to search the current directory and its subdirectories.

To search several directories for files with certain permission codes, type: find dira dirb dirc -perm -0600 -print

Find files in multiple directories in Linux

If we want to search and list all files with a given name in multiple directories, we can either start the search at root folder, or if we know the directories, we can specify them.

Example: find ./test ./logs -name failed*.* -type f

Find Files with change time in Linux

To list all files in the current directory that are changed during the current 24-hour period, type: find . -ctime 1 -print

Find Files with multiple Links in Linux

To search for regular files with multiple links. This command lists the names of the ordinary files (-type f) that have more than one link (-links +1). Note: Every directory has at least two links: the entry in its parent directory and its own . (dot) entry. The ln command explains multiple file links. find . -type f -links +1 -print

Find Files with names in Linux

To find all accessible files whose path name contains find, type: find . -name ‘*find*’ -print

To remove all files named a.out or *.o that are not accessed for a week and that are not mounted by using nfs, type:

find / \( -name a.out -o -name ‘*.o’ \) -atime +7 ! -fstype nfs -exec rm {} \;

Note: The number that is used within the -atime expression is +7. It is the correct entry if we want the command to act on files that are not accessed for more than a week (seven 24-hour periods).

Find Files with Files size in Linux

To search for all files that are exactly 414 bytes long, type: find . -size 414c -print

And to find files that are greater than a certain size, we use: find ./test -size +2M

The above will find all the files which are greater than 2MB in the ./test folder. When looking for files within a specific range such as between 100 and 200 MB

find / -size +100M -size -200M

Find Large files in Linux

The first step of extracting files larger than 200 MB was a success. The next target is to get the files sorted according to their sizes. This can be done by:

find / -xdev -type f -size +200M | xargs du | sort -k 1 -rh

Find exec command Combination in Linux

To find and remove every file in our home directory with the .c suffix, type: find /u/arnold -name “*.c” -exec rm {} \;

Every time the find command identifies a file with the .c suffix, the rm command deletes that file. The rm command is the only parameter that is specified for the -exec expression. The {} (braces) represent the current path name. We can check more about Linux find exec command here.

Find Files with Links in Linux

In this example, dirlink is a symbolic link to the directory dir. To list the files in dir by referring to the symbolic link dirlink on the command line, type: find -H dirlink -print

Find files with ls command in Linux

To produce a listing of files in the current directory in ls format with expanded user and group name, type:  find . -exec ls {} \;

Find Files with ACL in Linux

To list the files with ACL/EA set in current directory, type:  find . -ea

Find Files with modifying time in Linux

To list the files that are modified within 60 minutes, type: find . -mmin -60


Welcome to!

Our website is dedicated to providing comprehensive information on using Linux.

We hope you find our site helpful and informative, and we welcome your feedback and suggestions for future content.

Learn More