Unix find command with examples and common usage

Published September 01, 2009

All these examples search for files under the location /apps

file name and strings

search for files named server.properties

find /apps -name server.properties

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

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: September 01, 2009.     This post was originally written on September 02, 2009.