

As seen in the above examples, the find command can be used to filter and search the files and folders with various options and criteria.īeing a Linux user, having good knowledge of the find command will be very helpful as we depend on the terminal for most of the tasks rather than the GUI.
LINUX NETATALK SERVER HOW TO
In this article, we learned about the syntax of the find command along with various examples of how to make the most of the find command in Linux. find / -type f -perm 0777 print -exec chmod 644 \ Conclusion To find the files with permissions 777 and set their permissions to 644 using the chmod command. Find files with 777 permissions and chmod to 644 To find the files with 777 permissions, the following command is used. The files which are accessed in the last 1 hour can be found using the following command find / -amin -60 17. The files which are modified in the last 1 hour can be found using the following command find / -mmin -60 16. We need to enter the hour in minutes, like 60 minutes for 1 hour like in the following command. Find the changed files in the last 1 hour find / -mtime +20 -mtime -50 Search the modified files with specific days 14. Let’s say that we need to find the modified files which are more than 20 days and less than 50 days, type the following command. Find modified files within the specific days find / -atime 30 Search the accessed files of last 30 days 13. Similar to finding the modified files, we can find the accessed files from the last 30 days. We can also find the files which are modified 30 days back using the command, find / -mtime 30 Search the modified files of last 30 days 12. find /home -user userName -iname "*.txt"įind /home -user ubuntu -iname "*.txt" Search particular files of the user 11. txt filesof user ubuntuunder the /home directory. If we want to find the particular type of files that belongs to the user, say that we need to find all the. To find all the files that belong to the group Devopsunder the directory find /home -group groupName 10. find /home -user userName Search files based on the user 9. The below command will find all the files that /homebelong to user userName say for example, ubuntu, under the /home directory. The previous command displayed a single file from the root directory. To find a file named test.txt under the root directory / of the owner root, this command is used. type f -name "*.php" Search the PHP files in a directory 7. To display all the PHP files in a directory the following command is used. type f -name test.php Search the PHP file with name 6. To find the php files with the name test.php use the following command. find / -type d -name Test Search directories using the name 5. This command will help us find the directories named Test under the / directory. find /home -iname test.txt Search the files ignoring the case 4. whether it is uppercase or lowercase, our command gets all the files under the name test.txt under the home directory. The following command gets us the files with the name test.txt ignoring the case, i.e. Find files using the name ignoring the case

find /home -name test.txt Search a file under home directory 3. The file with the name test.txt which is under the home directory can be found using the following command. name test.txt Search a file with specific name 2. The following command will help us in finding the file named test.txt in the current working directory.

Linux users cannot just rely on GUI to perform various tasks in their system.
