In the world of Linux, finding files efficiently is an essential skill for system administrators and everyday users alike. With a plethora of directories and countless files, searching for specific files can become a daunting task. However, Linux offers several powerful tools and commands that can help simplify this process. In this comprehensive guide, we will explore different methods to find files on Linux, using the example of searching for a specific file called “neuronvm.txt”. Whether you are a beginner or an experienced Linux user, this guide will provide you with clever tricks to locate files quickly and efficiently.
In this section, we will examine some of the main Find commands with examples so that you can have a better understanding of them. The Find command has a wide range of options and allows people to search for files based on a variety of criteria.
You can go to Linux VPS or the operating system. Open the terminal and use these commands to find the files rapidly:
1- Use the command below to find files in the current working directory:
Note: We will use neuronvm.txt as our file name.
find . -name neuronvm.txt ./neuronvm.txt
2- Finding files under home directory:
find /home -name neuronvm.txt /home/neuronvm.txt
3- Use this command to find all the files whose name is neuronvm.txt with both capital and small letters in /home directory:
find /home -iname neuronvm.txt ./neuronvm.txt ./neuronvm.txt
4- To find directories under / directory with the name neuronvm:
find / -type d -name neuronvm /neuronvm
5- You can find all the PHP files with the name neuronvm.php in the directory:
find . -type f -name "neuronvm.php" ./neuronvm.php ./login.php ./index.php
Here we will give you some examples to find files using their permissions.
1- Finding all the files whose permissions are 777:
find . -type f -perm 0777 -print
2- If you want to find files without 777 permission:
find / -type f ! -perm 777
3- To find all the SGIC bit files with permissions set to 644:
find / -perm 2644
4- To find Sticky Bit files and their permission 551, use the following command:
find . -type f -perm 644 -ls | grep 'SGIC'
5- Use the command here to find all the SUID files:
find / -type f -perm /4000
Here we will give you some examples of commands for finding files based on owners and groups:
1- If you want to search for all files or a single file called neuronvm.txt under /root directory of the owner root, use the following command:
find / -user root -name neuronvm.txt
2- You can use the command below if you want to find all files belonging to user neuronvm under /home directory:
find /home -user neuronvm
3- Apply this command to find files that belong to the group Developer under /home directory:
find /home -group developer
4- If you want to find all the .txt files for user neuronvm under /home directory:
find /home -user neuronvm -iname "*.txt"
In this section, you will see some examples of finding commands for locating files and directories based on date and time:
1- For finding the files which are modified 50 days ago:
find / -mtime 50
2- Use the following command to find the files which are accessed 50 days ago:
find / -atime 50
3- You can find the files which are changed in the last 1 hour, using the command below:
find / -cmin -60
4- For finding modified files in the last 1 hour:
find / -mmin -60
5- To find the files which are modified more than 50 days back and less than 100 days:
find / -mtime +50 –mtime -100
Here you will find some examples to find commands for locating files and directories based on size.
1- To find the files which are 50MB:
find / -size 50M
2- If you need to find the ones greater than 50MB and less than 100MB, use this command:
find / -size +50M -size -100M
3- Use this command to find and delete 100MB files:
Note: Just one single command will find and delete all 100MB files.
find / -type f -size +100M -exec rm -f {} \;
4- Finally, If you decide to find all .mp3 files with more than 10MB and delete them, use this single command:
find / -type f -name *.mp3 -size +10M -exec rm {} \;
Efficiently finding files on Linux is crucial for both everyday users and system administrators, and Linux offers various techniques to simplify this process. By utilizing commands like ‘find’, employing wildcards, filtering by file types, and searching in specific directories, you can enhance your file search capabilities on Linux. With practice and familiarity, you will become adept at quickly finding files, regardless of their location or filenames. If you have any questions about find files on linux, you can contact us in the comments section. If you find this post useful, please share it with others.
How useful was this post?
Click on a star to rate it!
Average rating 5 / 5. Vote count: 1
No votes so far! Be the first to rate this post.
Remote Desktop Protocol is a technology developed by Microsoft that allows users to remotely connect...
If you are looking for a convenient and easy-to-use solution for remote access and support, we can r...
What is your opinion about this Blog?