| How to find files in Linux |
|
| sysadmin |
|
This article describes how to find files in Linux.
locateThe fastest way to find a file on Linux is by using the "locate" command. If you know the name of the file or just a part of the name you can use the locate utility to list all files / directories that contain this pattern.
example:
What is this: "warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old" ?Locate will only find files which have been added to the slocate database. To make sure all files are added to the slocate database we can run 'updatedb' from a shell:
or as a cronjob:
You can also run updatedb with the "-l 0" option: If FLAG is 0 or no, locate outputs the database entries even if the user running locate could not have read the directory necessary to find out the file described by the database entry. I would not do that on a server but it is very nice on a Desktop system.
findWith "find" you can search for files based on some user-specified criteria. Here are some nice examples:
find a file named test.txt and start at "/":
search the current directory: --> If no paths are given, the current directory is used
find all files containing test and start at "/":
find all files larger than 1 Megabyte (1024kb) and start at "/":
find all files larger than 1 Megabyte (1024kb), start at "/" and only search in the "/" filesystem (don't descend directories on other filesystems):
find all files in your HOME folder that have NOT been modified in the last year:
Comments (0)
Powered by !JoomlaComment 4.0 beta1
!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved." |

