Chapter #4: Learn to Search, Filter, and Identify Files in Linux
In this article, we show you how to efficiently find and classify files in Linux using find, file, and type - ideal for anyone learning Linux administration.

In the previous chapter, you learned how Linux manages users, groups, permissions, and ownership of files and directories, which is an essential part of system administration.
Now that you know who can access what, itβs time to figure out where everything is and what kind of files you're dealing with.
As systems grow, finding files by manually browsing through directories becomes inefficient. Thankfully, Linux provides powerful tools to search for files, filter them based on various criteria, and even describe what kind of data they contain, regardless of their file extension.
In this chapter, you will learn how to:
- Use the
find
command to locate files and directories based on name, size, type, time, ownership, and more. - Identify file types with
file
- a useful way to figure out what a file is when its name isn't obvious. - Use
type
to learn whether a command is built-in, an alias, or an external program. - Practice what youβve learned through hands-on exercises.
Mastering these commands is key when youβre working with complex file systems or need to automate tasks based on file attributes.
Letβs get started!
Finding Files in the System
The find
command is used to search recursively through directory trees for files or directories that match certain characteristics.
Subsequently, it can either print the matching files or directories or perform other operations on the matches.
We can search for files by name, owner, group, type, permissions, date, and other criteria.
Searching for Files by Name
To search for a file by name, we will use the -name
option. We can use wildcards if we enclose pattern in quotes.
As a result, find will locate files that match the wildcard filename. The following example will locate all files with a name ending in .sh
inside /home/gacanepa
:
find /home/gacanepa -name "*.sh"
This command tells find
to:
- Search recursively in the
/home/gacanepa
directory, - Match any file ending in
.sh
(shell scripts), - And return the full path of each matching file.
"*.sh"
are important to prevent the shell from expanding the wildcard before find
runs.Searching by Permissions
Sometimes we need to locate files based on their permission settings - for example, to find executable files or files that are writable only by the owner. The find
command makes this easy using the -perm
option.
If we precede the mode with a +
(plus sign), find
locates files in which any of the specified permission bits are set.
If we precede the mode with a -
(minus sign), find
locates files in which all of the specified permission bits are set.
To find all files that can be executed by any user, located inside the current directory (represented by a dot) and descend recursively down to 3 levels (using -maxdepth
):
find . -maxdepth 3 -type f -perm -o=x
This command breaks down as follows:
.
- start searching in the current directory-maxdepth 3
- search only 3 levels deep-type f
- look for files only (not directories)-perm -o=x
- match files where all users have execute permission
This is especially useful for auditing scripts or binaries scattered in subdirectories, making sure they're accessible as needed.