LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find a file on entire drive question (https://www.linuxquestions.org/questions/linux-newbie-8/find-a-file-on-entire-drive-question-720536/)

R4ndom 04-20-2009 06:57 PM

find a file on entire drive question
 
I know this is simple but I cannot find out how to issue a command (like 'whereis' or 'find') to look for a file on my entire hard drive. I have backtrack installed on /dev/sda6 and I was looking for a couple files (like 'bashrc') but I cannot figure out what should be added to force linux to look through all of the sub-directories. Can anyone help?

Robhogg 04-20-2009 07:13 PM

Code:

find / -name filename 2>/dev/null
find will automatically work recursively through all the directories below the one(s) you give it to start with (in this case / - the root directory) and -name says to search by name (you can use wildcards such as filen*) - there are many ways of searching with find.

The 2>/dev/null command is only really necessary if you execute the command as a non-root user (otherwise the results will be drowned in "Permission denied" error messages). 2 is the "file descriptor" for the standard error stream, and the > redirects the error messages to /dev/null (otherwise known as the bit bucket.

Oh, and bashrc is normally .bashrc (the leading dot indicates a hidden file).

Hope this helps,
Rob.

R4ndom 04-20-2009 07:37 PM

Thanks for the help. That worked flawlessly.

syg00 04-20-2009 08:01 PM

You might find this useful.
I have no idea why it is hidden under Security.

Note that the find command can be used like this on a filesystem - on a multi-partitioned disk, searching the "entire disk" becomes a little more problematic.


All times are GMT -5. The time now is 10:35 AM.