10 Linux Find Command Examples

by lifeLinux on September 8, 2011

The Linux find command is very powerful. It can search the entire filesystem to find files or directories according to the search criteria that you specify. In this article, I’ll show 10 examples of Linux find command that will be very useful to both newbies and experts.

1. Find files using name

# find /etc -name passwd

Sample ouputs


2. Find files using name and ignoring case

# find /etc -iname Passwd

Sample ouputs


3. Find files based on file type

Find only the socket files

# find . -type s

Find all directories

# find . -type d

Find only the normal files

# find . -type f

4. Find files by modification time

# find . -mtime -7

Sample outputs


5. Find Files by Size

Find files bigger than 100MB

# find /var -size +100M

Sample outputs


Find files smaller than 100MB

# find /var -size -100M

Sample outputs


6. Find files using permission

# find /var -perm 777

Sample outputs


7. Find and delete

Clean PHP files

# find . -iname "*.php" -exec rm -rf {} \;


# find . -iname "*.php" -print | xargs rm –f

8. Find all empty files

# find /var -empty

Sample outputs


9. Finding files only in current directory not finding on sub directories

# find /etc -maxdepth 1 -name passwd

Sample outputs


10. Find files with different file extensions

# find / -type f \( -name "*.php" -o -name "*.php5" \)

Sample outputs


Previous post:

Next post: