LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   the "whereis" LINUX command (https://www.linuxquestions.org/questions/linux-newbie-8/the-whereis-linux-command-4175453424/)

Siaw 03-09-2013 01:18 PM

the "whereis" LINUX command
 
i don't understand the whereis command in the linux terminal. it's used to find files. i search the internet and what they showed me is not comprehensible. how do i use the "whereis" command? please.

unSpawn 03-09-2013 01:24 PM

Code:

# Only locations:
 ~]$ which ls
        /bin/ls

# Only manual pages:
 ~]$ whatis ls
ls                  (1)  - list directory contents
ls                  (1p)  - list directory contents

# The answer to life, the universe and everything:
 ~]$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz


shivaa 03-09-2013 01:51 PM

It's manual has all answers, just go through it (see here)

Take a note, whereis won't search for files, but whereis locates source/binary and manuals sections for specified files.

Code:

~$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

But if you will search for a simple file, it will return nothing, execpt filename itself:
Code:

~$ whereis foo
foo:


Siaw 03-09-2013 02:07 PM

thanks you very much :)

David the H. 03-12-2013 09:40 AM

To locate regular files by name or pattern, you should generally use the locate command (imagine that ;)).

Be aware, however, that locate works by reading a previously-indexed snapshot of your system tree, created by the updatedb program. If changes have been made since the database was last refreshed you can get inaccurate results. Most distributions set up an automatic cronjob to run updatedb for you, usually once a day.

For truly up-to-date results, you need to use find instead:

http://mywiki.wooledge.org/UsingFind
http://www.grymoire.com/Unix/Find.html


All times are GMT -5. The time now is 12:32 AM.