Differences between revisions 7 and 8
Revision 7 as of 2008-10-03 20:20:19
Size: 2511
Editor: localhost
Comment: converted to 1.6 markup
Revision 8 as of 2011-01-01 16:14:38
Size: 213
Editor: 211
Comment: o4Iz1x <a href="http://shqaklcbkdsg.com/">shqaklcbkdsg</a>, [url=http://nsoingwvzasz.com/]nsoingwvzasz[/url], [link=http://gumlsuiazane.com/]gumlsuiazane[/link], http://myghauabvlkf.com/
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Finding Files in Linux ==

There are three good methods of finding files in linux:

  1. The slocate database
  1. The whereis command
  1. 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".

If you read Chinese, here is a detailed explaination about
[[zh]]
[[../如何在Linux上用find查找文件]]
[[en]]

==== Locating man pages by subject ====

There is a keyword option in the man command that can be used to find man pages that have specific words in their descriptions. An example is:
{{{
man -k process
}}}
to find all man pages that talk about processes. Use the command:
{{{
man -k process |grep kernel
}}}
to find information on kernel processes. An equivalent command is the apropos command as follows:
{{{
apropos process
}}}

==== The which command ====

The which(1) program is a useful command for finding the full path of the executable program that would be executed if the name of the executable program is entered on the command line. The command:
{{{
which startx
}}}
Will show the full path of the startx command that will be run if "startx" is entered on the command line when an X session is started.
o4Iz1x <a href="http://shqaklcbkdsg.com/">shqaklcbkdsg</a>, [url=http://nsoingwvzasz.com/]nsoingwvzasz[/url], [link=http://gumlsuiazane.com/]gumlsuiazane[/link], http://myghauabvlkf.com/
----
CategoryCategory

JunHu: JunHu/Memo/FindingFiles (last edited 2011-01-10 22:52:53 by JunHu)