Last Updated on 2 months by Sachin G
One of the first challenges I faced when I started working with Linux was finding files buried deep within directories. The Linux terminal is powerful, but it can be intimidating when you’re not sure how to search efficiently. Over time, I’ve tested various methods, and in this post, I’ll share 7 reliable and tested ways to find files and directories using the Linux command line. The Find command is the best tool to perform a real-time search in the Linux file system to find files.
What Happened When I Tried the find
Command
When I first used the find
command, I was honestly overwhelmed by the number of options. But once I got the hang of it, it became my go-to for everything—from locating lost config files to cleaning up logs.
General Syntax of the find command is below, and it usage is below in the uses methods.
# find Search_Path Options Expression
Example :
find / -name "filename.txt"
This command scans your entire file system. It’s part of the file search utilities that every Linux user should master. You can also customize it with search parameters like file size, type, or modification time. To search files user must have read and execute permission on a directory to inspect its contents.
The find command has a large number of options that depend on the type of file should be found.
Search_Path: This is the path where find will filter the files or expressions
Options: This argument will be used to customize our output as needed.
Expression: This attribute searches for a file name and return on all results that are match.
Why It Works:
Supports deep, recursive search
Finds files based on name, type, size, and more
Great for both directories and hidden files
Below are 7 different methods for searching in the Linux file system :
1. Find Files by Type ( -type option)
The –type option followed by the given file type, like regular file, directory, soft link file, and block device files.
# find /home –type d ( For Directory )
# find /bin –type l ( For soft Link files)
# find /dev –type b ( For Block device files )
# find /home –type f ( For Regular files )
2. Find Files by Name ( -name option)
Here is the –name option that takes after with file name will fetch exact matches given the file name. If we need to search for any file that contains passwd anywhere in the etc directory and all subdirectories, we will execute below command.
#find /etc –name '*passwd*'
3. Files for case–insensitive ( -iname option)
You want to ignore case in searching through the find command, like yo do not know the case, it could be lowercase, uppercase, or any of them, you can run find command with –iname option. Syntax will be like below.This is called as case insensitive searching through the find command.
# find / -iname ‘*passWD*’
4. Files by user ( -user option) and ( -group option )
Through –user and –group option find can also search files of the owner and group ownerships based. Now if you want to search those files which is owned by user username like techtransit in the home directory of techtransit user then you have to run below command for this.
# find /home/techtransit -user techtransit
And if you want to look those files in home directory of user techtransit , which is owned by group techtransit . Run the below command.
# find –group techtransit
You can also user both parameter together like , as I have show .
# find Search_path -user username –group groupname
5. Find Files by Permission ( -perm option)
Searching files by permission is a little complex. The –perm option will be used to search through permissions, it looks for files with a particular set of permissions.
Here we are using the octal value of permission to search files. The below command will match any files that the user has read, write, and execute permission, and group members and others have read-only access in the /etc directory.
# find /etc –perm 744
Now we are going to describe the – and / value.
‘-‘ we are using for at least permission match like to find files which owner or user has at least read, write , group and other have at least write access.
# find /etc –perm -644
To search file which the user or group has read permission or others have at least read read and write access.
# find /etc –perm /446
When we used / or – value in perm , the 0 works like a wild card , this means having a permission at least nothing .
Example : Below command will find all files in /etc/ directory where others have write permission .
# find /etc –perm -002
6. Get Files by Size ( -size option )
Files also can search according to the size through below option.
Below command is for exact size match 25 megabyte on root files system.
# find / –size 25M
+ Sign in size parameter search all file which is more than size define.
# find –size +25G
-Sign in search all files , which is less than size define.
# find –size -25G
7. Files by Time ( –mmin option )
The mmin option is for searching a file that had their content has been changed at exactly the given time in the past.The below command will search those files which has changed exactly 20 minutes ago in the etc directory.
# find /etc –mmin 20
+ and – operand in front of the mmin option will look for all files in the /etc/ that have been modified more than or less than the given time.
Two more thing I wanted to share that find and grep with combined usages and one is simple case study.
Combining find
and grep
for Deep Search
When I set this up, I ran into some permission errors. But after adjusting to sudoIt worked perfectly:
find /var/www -type f -exec grep -l "database_name" {} \;
This combo is gold when you’re unsure about both the file name and its location. It merges the power of command line tools for maximum control.
Case Study: Searching for Hidden Files
I had to search for hidden files in Linux to fix a permission issue.
find ~ -name ".*"
This command surfaced all dotfiles, some of which had incorrect permissions. It’s a reminder of how Linux hides critical files by default.
Every method has its use case. Personally, I rely on find
and grep
daily. For quick tasks, I go for locate
.Though this post focuses on Linux terminal usage, I once tried GNOME Search Tool on Ubuntu. It’s ideal for users not yet comfortable with shell commands. It’s intuitive and supports filename, date, and content-based filtering.
I’m Sachin Gupta — a freelance IT support specialist and founder of techtransit.org. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!