LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 02-19-2009, 12:14 PM   #1
ak.lokesh
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Rep: Reputation: 0
Find a file path and directory path


Hi All,

What is the command we need to use to find out a path for a particular file and directory??

Thanks in advance.
 
Old 02-19-2009, 12:29 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,769

Rep: Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614
Quote:
Originally Posted by ak.lokesh View Post
Hi All,

What is the command we need to use to find out a path for a particular file and directory??

Thanks in advance.
Take a look at either the locate or find commands. Type in "man locate" or "man find". You don't say anything about the version/distro of Linux you're using.....
 
Old 02-19-2009, 12:35 PM   #3
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
You can use which,find and whereis commands.
Code:
 which firefox
/usr/bin/firefox
Code:
 whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /usr/bin/X11/firefox /usr/share/man/man1/firefox.1.gz
Code:
 
find / -name firefox
/usr/lib/firefox
/usr/lib/firefox/firefox

Last edited by alan_ri; 02-19-2009 at 12:43 PM. Reason: adding find command example
 
Old 02-19-2009, 12:37 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949
What is the context or purpose for needing this information?

For files in the current directory, all you need to know is where that directory is, which you can get with the pwd command. For programs and system commands you can use which; "which mplayer", for example. Note that some commands are shell built-ins or aliases and such, and won't give you any output.

As for other files on the system, if you don't already know where they are, then you can't rightly run any commands on them, can you? All you can do is use find or locate to search for them.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Perl, Removing file from path to get directory only xemous Programming 8 04-11-2012 11:13 AM
List file names in a directory WITHOUT the path dexus Linux - Newbie 13 06-13-2009 07:22 PM
Find path from file alias an_sush Linux - Newbie 2 02-12-2009 06:15 AM
Find file/dir path nc3b Programming 5 08-28-2006 04:49 AM
how to find a relative path to another directory bahadur Programming 9 04-04-2005 07:52 PM


All times are GMT -5. The time now is 02:56 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration