Finding Files

Finding Files

There are three good methods of finding files in linux:
  1. The slocate database
  2. The whereis command
  3. The find command

The slocate database

To use the locate command, you will need to have a slocate database set up on your system. On many systems it is updated periodically by the cron daemon. Try the slocate command to see if it will work on your system:
locate whereis
Will list all files that contain the string "whereis". If that command did not work you will need to run the command:
slocate -u
This command will build the slocate database which will allow you to use the locate command. This command will take a few minutes to run.

The whereis command

This command will locate binary (or executable) programs and their respective man pages. The command:
whereis linuxconf
will find all binaries and manpages with the name linuxconf.

The find command

The following are examples of the find command:
find /home -user mark

Will find every file under the directory /home owned by the user mark.
find /usr -name *spec

Will find every file under the directory /usr ending in ".spec".
find /var/spool -mtime +40

Will find every file under the directory /var/spool that has data older than 40 days.
Find is a very powerful program and very useful for finding files with various characteristics. For more information, read the man page about find by typing "man find".

0 comments:

Post a Comment