LinuxQuestions.org
Review your favorite Linux distribution.
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
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
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: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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
List file names in a directory WITHOUT the path dexus Linux - Newbie 16 11-09-2016 07:58 PM
Perl, Removing file from path to get directory only xemous Programming 8 04-11-2012 11:13 AM
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

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

All times are GMT -5. The time now is 01:23 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