Find Command On Linux

[Total: 3    Average: 5/5]

Find Command On Linux


Find command is a very useful command to search for files from the command line. Find command used to search and locate list of files and directories, Find command can be used in variety of conditions like you can find files by permissions, users, groups, file type, date and size. The find command is available on most linux distros by default so you do not have to install any package. In this article I’ll take a look at the most common uses of the find command.

1) Find all php files whose name is test.php in a current working directory.

[root ~ ]# find . -type f -name test.php


2) Find all directories whose name is milind in / directory.

[root ~ ]# find / -type d -name milind


3)Find all the files whose permissions are 777.

[root ~ ]# find . -type f -perm 0777 -print


4)Find Files with 777 Permissions and Chmod to 644

[root ~ ]# find . -type f -perm 0777 -print -exec chmod 644 {} \;


5) Find Directories with 777 Permissions and Chmod to 755

[root ~ ]# find . -type d -perm 777 -print -exec chmod 755 {} \;


6) Find and remove File

To find a single file called test.txt and remove it.

[root ~ ]# find . -type f -name "test.txt" -exec rm -f {} \;


7)Find all files that belongs to user milind under /home directory.

[root ~ ]# find /home -user milind