track ip addresses, phone numbers, etc

Unix find command with examples and common usage

Published on 01 September 2009

All these examples search for files under the location /apps

file name and strings

search for files named

find /apps -name

search for string "JAVA_HOME" in all files

find /apps -exec grep "JAVA_HOME" '{}' /dev/null \; -print

search for files by user USER123

find . -user USER123

file size

Find files greater than 1GB

find /apps -size +1024000k -print

Find files greater than 1GB and

find /apps -type f -size +1024000k -exec ls -al {} \;

files last modified

Find files modified less than 7 days back

find /apps -mtime -7 -print

Find files modified longer than 7 days ago

find /apps -mtime +7 -print

file permissions

Find files that are executable

find /apps -perm -100 -print

Find files that have permissions -r--r--r--

find /apps -perm 444 -print

Find directories that have write permissions

find /apps -type -perm 777 -print

files with extensions

Search for *.log files under /apps

find /apps -name '*.log' -print

files by type

Search for softlinks

find /apps -type l -print | xargs ls -l

using xargs

Find files with executive permission and remove the x permission for groups and others

find /apps -perm -20 -exec chmod go-x {} ;

You can also use this:

find /apps -perm -20 -print | xargs chmod go-x

Last Update: 01 September 2009 [Created on 02 September 2009]

Affiliate Disclosure: Some of the links to products on this blog are affiliate links. It simply means, at no additional cost to you, we’ll earn a commission if you click through and buy any product.