Although the popular use of the find command is to search within the folder path with its option, it can also meet much more specific needs when customized.

The basic usage is as follows:

find [search-to-directory] [option] [search-org]

Let’s start with examples. Our first example is to find the error.log files on the server.

find / -name "error.log"

Or using type;

find / -type f -name "error.log"

When this command is applied, the error.log files found in other services in the system will also be listed. If we want to find all *.log files on the server, the following command will be useful.

find / -name "*.log"

Let’s search multiple files at once. The files we want to find are access.log and error.log.

find / -type f ( -name "access.log" -o -name "error.log" ) -print

we are not limited to searching only filenames. Let’s take a look at -type expressions before folder searches.

  • b: block device
  • c: character device
  • d: directory
  • f: regular file
  • l: symbolic link
  • P: FIFO
  • s: socket

Now let’s perform a folder search.

find / -type d -name [folder-name]

Let me remind you that all operations are case-sensitive. We can use -iname to perform search operations without distinction of upper and lower case.

find / -type d -iname [folder-name]