Linux: How do I find files in Linux (using locate or find)? [CentOS, RHEL, Redhat, Fedora]

March 24, 2008 – 2:03 am

There are few ways to find files in Linux. Each have their own advantages and disadvantages. Some are distribution specific and some are not installed by default. Let us start with fastest way to find files using locate and secondly we will talk about using find: a very powerful and utility which is available in almost all distributions to help users find files in Linux.

  1. locate
    • Usage: locate <what you are looking for>
    • Example: locate whois
    • Advantages: Looks through database therefore is really fast
    • Disadvantages: database has to be updated in order to find new files.
  2. find
    • Usage: find <path> –name “<what you are looking for>”
    • Example: find / –name “whois”
    • Advantages: No database to use; lots of advance features
    • Disadvantages: Can be slow; requires more typing even for simple search

Both of the above methods used for finding files in Linux can have many parameters. You can read the man page of locate or man page for find to read more ways to running the commands to find files.

Post a Comment