The Fragmented Search
When searching for a lost configuration file or a specific error log on an Ubuntu Linux server, the target could be located in several different, completely unrelated directories. Standard tutorials often demonstrate searching the entire root file system (find /), but if you have terabytes of data, searching the root drive will take hours. Conversely, running a separate search command for every single possible directory (e.g., searching /var/log/, then waiting, then searching /etc/) is highly inefficient. You must instruct the search engine to scan multiple targeted locations simultaneously in a single command.
Using the find Command with Multiple Paths
The Linux find command allows you to define an unlimited number of starting directories simply by chaining them together with spaces before you declare your search flags.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To search both the
/var/log/directory and the/etc/nginx/directory simultaneously for any file namederror.log, type the following command exactly:sudo find /var/log/ /etc/nginx/ -name "error.log" - Press Enter and provide your administrator password.
Optimizing the Output
The search engine will sequentially scan the first declared directory, then immediately scan the second, and combine all the results into a single output list in your terminal. You can add as many directories as necessary (e.g., sudo find /var/ /etc/ /opt/ /home/ -name "config.php"). By explicitly defining only the directories where the file might logically exist, you completely bypass scanning irrelevant folders (like your media storage or database binaries), resulting in a lightning-fast search that takes seconds instead of hours.