Cheat Sheet: 21 useful find commands

Written by Benjamin Cane on 2012-07-22 | 1 min read

For todays article I wanted to put together a quick little cheat sheet for some GNU find command examples.

Some of these commands will be basic some will be more advanced, but they all will be useful. As a caveat some commands don't work in all Unix environments and this is especially true with older releases. If you find yourself in one of those situations there is a way to make the find command work you will just need to use different methods like the -exec flag.

Find things by name

 # find /path/to/search -name filename


 # find /etc -name hosts

Find things by name (case-insensitive)

 # find /path/to/search -iname filename


 # find /etc -iname HOSTS

Find only files by name

 # find /path/to/search -name filename -type f


 # find /etc -name network* -type f

Find only directories by name

 # find /path/to/search -name dirname -type d


 # find /etc -name network* -type d

Find all symlinks

 # find /path/to/search -type l


 # find /etc -type l

Find things by owner

 # find /path/to/search -user owner


 # find ./ -user root

Find executable files

 # find /path/to/search -type f -executable


 # find ./ -type f -executable

Find SUID files

 # find /path/to/search -perm -4000


 # find /sbin -perm -4000

Find things changed today

 # find /path/to/search -daystart -ctime -1


 # find ./ -daystart -ctime -1

Find things changed in the last 24 hours

 # find /path/to/search -ctime -1


 # find ./ -ctime -1

Counting how many things you find

 # find /path/to/search | wc -l


 # find ./ | wc -l

Deleting things you find

 # find /path/to/search -delete

Deleting things you find (with xargs)

 # find /path/to/search | xargs rm

Deleting things you find (with exec)

 # find /path/to/search -exec rm {} ;

Printing Type of file, Filename & Inode

 # find /path/to/search -printf "%y %i %prn"


 # find ./ -printf "%y %i %prn"
  d 4852409 ./

Finding Broken Symlinks

 # find /path/to/search -follow -lname "*"


 # find ./ -follow -lname "*"

Find files older than 31 days and delete them

 # find /path/to/search -mtime +31 -delete


 # find ./ -mtime +31
  # find ./ -mtime +31 -delete
  # find ./ -mtime +31

Remove Empty Directories

 # find /path/to/search -type d -exec rmdir --ignore-fail-on-non-empty {} + ;

Tar files changed today

 # tar -cvzf ../files_created_today.tgz `find /path/to/search -type f -daystart -ctime -1`

Find files bigger than X Size

 # find /path/to/search -size +


 # find ./ -size +100M

Using Regex with find

 # find /path/to/search -regex 'regex pattern (full path)'


 # find /var -regex '.*/tmp/.*[0-9]*.file'

Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review