Log in Go to the main page Page Discussion History Go to the file list Go to the site toolbox

Find command

From NetworkCommands


Image:Tux_64x64.png

A command line program available on most Unix and Linux systems; used to search for files and/or directories.

Contents

Image:Vm-power-on-medium.png Usage Syntax

find path [option] string [[option] string]]...

Common options include;

  • -name - find files by name
  • -user username - find files owned by the specified user
  • -type (d|f|l) - find only files, directories or symbolic links
  • -size - find only files equal to, greater or smaller than the specified size
  • -perm - find files by permissions
  • -mtime days - find files last modified within the specified number of days
  • -atime days - find files last accessed within the specified number of days
  • -ctime days - find files that last had their permissions changed within the specified number of days
  • -mmin minutes - find files last modified within the specified number of minutes
  • -amin minutes - find files last accessed within the specified number of minutes
  • -cmin minutes - find files that last had their permissions changed within the specified number of minutes

Image:accessories-text-editor-v2-medium.png Usage Notes

When searching by file name string can be composed of any combination of characters and regular expressions.

As indicated above, multiple options can be used together to refine a search.

Image:Vm-power-on-medium.png Usage Examples

Image:Insert-text-small.png Find By Name

find . -name "*.conf"

Image:System-users-small.png Find By User

find . -user username

Image:Insert-text-small.png Image:System-users-small.png Find By Name & User

find . -name "*.conf" -user apache

Image:System-users-small.png Find By Non-existant User

find . -nouser

Image:X-office-drawing-small.png Find By Type

find . -type d - Only directories

find . -type f - Only files

Image:Object-flip-horizontal-small.png Find By Size

find directory -size +1024M

find directory -size -600c

  • b - for 512-byte blocks (default)
  • c - for bytes
  • k - for Kilobytes (units of 1024 bytes)
  • M - for Megabytes (units of 1048576 bytes)
  • G - for Gigabytes (units of 1073741824 bytes)

Image:Office-calendar-small.png Find By Day

find . -mtime -1 - Modified in the last 1 day

find . -atime -1 - Accessed in the last 1 day

find . -ctime -1 - Permissions changed in the last 1 day

Image:Appointment-soon-small.png Find By Minute

find . -mmin -5 - Modified in the last 5 minutes

find . -amin -5 - Accessed in the last 5 minutes

find . -cmin -5 - Permissions changed in the last 5 minutes

Image:Dialog-password2-small.png Find By Permissions

find . -perm 777

Operators

! - Except

-o - Or

Image:accessories-text-editor-v2-medium.png Linux Usage Notes

With most Linux or Unix commands;

  • Brief help can be displayed using the option/keyword: -h or --help, for example: chmod --help
  • A full command manual can be displayed using the man command followed by the command name, for example: man chmod
  • Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
  • Version information can be display using the option/keyword: -v or --version, for example: chmod --version


Image:icemon-medium.png Related Articles

You may find our regular expressions guide useful

Information on other Linux commands Image:Tux-small.png

Information on F5 BigIP commands Image:F5-logo-small.png

Information on Cisco commands Image:Cisco-logo-small.png

Information on Vyatta commands Image:Vyatta-logo-small.png

Information on Extreme commands Image:Extreme-logo-small.png

Information on Blue Coat SGOS commands

Information on Nokia IPSO commands


Image:internet-group-chat-small.png We really do appreciate all feedback so please do send your comments, suggestions or corrections to steve#networkstuff.eu (replacing the # with an @)



Site Toolbox:

Personal tools
This page was last modified on 8 December 2008, at 13:14. - This page has been accessed 68 times. - Disclaimers - About NetworkCommands
Powered by MediaWiki