Usage of Find Command with Examples

Hi All,

Find is a very important command for system administrator to do their daily works. Most of the Linux distribution’s comes prepacked with the “find” command tool to search for files. Now lets see how to use find command with examples.

1. Find Files Using Name in Current Directory

Find all the files whose name is test.txt in a current working directory.

2. Find Files Under Home Directory

Find all the files under /home directory with name test.txt.

3. Find Files Using Name and Ignoring Case

Find all the files whose name is tecmint.txt and contains both capital and small letters in /home directory.

4. Find Directories Using Name

Find all directories whose name is test in / directory.

5. Find HTML Files Using Name

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

6. Find all PHP Files in Directory

Find all html files in a directory.

7. Find Files With 644 Permissions

Find all the files whose permissions are 644.

8. Find Files Without 644 Permissions

Find all the files without permission 644.

9. Find all Empty Files

To find all empty files under certain path.

10. Find all Empty Directories

To file all empty directories under certain path.

11.Find Specific Files and Delete

Find all .mp4 files with more than 50MB and delete them using one single command.

# find / -type f -name *.mp4 -size +50M -exec rm {} \;

 

Thanks for reading this tutorial, Hope you have enjoyed it 🙂

About

View all posts by

Leave a Reply

Your email address will not be published. Required fields are marked *