No, find
by default traverses all available levels:
sudo find / -mount -name 'myfilename'
If you have a separate home partition, or a encrypted home, or a secondary hard drive, you may want to list their mount points too, next to /
, for example
sudo find / /home/enzotib /media/data -mount -name 'myfilename'
The -mount
option is needed to avoid to traverse mounted filesystems. Among these there are /proc
, /dev
and /sys
, that is convenient to skip.
An alternative to traverse all files, avoiding only these last three paths is
sudo find /!(proc|sys|dev) -name 'myfilename'
you usually tell find where to begin the search, and what to look for. So the syntax for paths to search and what you're actually trying to find is different.
For the use case you mention, let's assume you want to find the passwd
file in /etc
:
find /etc/ -name passwd
you're saying "starting in etc, look for a file whose name is passwd
if you don't specify criteria (or "options" in find parlance), what find does is, it starts in the path (or paths) you specify, and finds all files and directories underneath, recursively. So the options "filter" those files to narrow down what you're looking for.
Find all JPG files anywhere in your filesystem:
find / -name "*jpg"
Using quotes in your options is recommended because otherwise shell expansion can cause you headaches.
Find any pdf files, regardless of case, in either Documents or Downloads:
find Documents/ Downloads/ -iname "*pdf"
If you do man find
and scroll down to TESTS, you will find all the "criteria" that find can use to narrow down your search. You can search for files with specific filenames, owned by specific users or groups, having a specific file permission, being of a specific type (e.g. -type d
will find only directories, while -type f
will find only plain files, excluding directories), files newer or older than a specific number of days (or minutes), files that are empty, that are executable, and so on.
In find's man page you will also find a section called ACTIONS, these can go after the criteria and will be triggered by any file that matches all the criteria. So you can have find
doing things like deleting files it finds, executing arbitrary commands on them, and so on.
But of course the basic syntax remains:
find [starting path(s)] [conditions or criteria]
Best Answer
This should do what you want:
If you want to find everything that could possibly be executable, you could look at mime-types or
file
output. That would be counter-productive though since you couldn't possibly catch every script.References:
The man page
Stackoverflow