LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2009, 06:57 PM   #1
R4ndom
LQ Newbie
 
Registered: Apr 2009
Posts: 7

Rep: Reputation: 0
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?
 
Old 04-20-2009, 07:13 PM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
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.

Last edited by Robhogg; 04-20-2009 at 07:16 PM.
 
Old 04-20-2009, 07:37 PM   #3
R4ndom
LQ Newbie
 
Registered: Apr 2009
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the help. That worked flawlessly.
 
Old 04-20-2009, 08:01 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solaris 9] find and grep entire disk noir911 Solaris / OpenSolaris 3 02-13-2008 05:51 PM
Cannot find SCSI drive with file manager KornFused Linux - Hardware 9 08-21-2006 06:13 PM
back up entire hard drive to image file? with a live cd n_md Linux - Software 2 02-01-2006 03:04 AM
find for an entire month Koven Linux - Software 7 07-26-2005 10:06 PM
Mirroring entire Hard drive guanyu Linux - General 7 03-04-2003 08:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration