About the commands

whereis


This command is used to locate the program and search for this in manual pages and source directories.


$whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/src/bin/ls
$whereis cd
cd: /usr/bin/cd /usr/share/man/man1/cd.1.gz
$cd /usr/bin/
$ls -l cd
-r-xr-xr-x  15 root  wheel  161 Feb  3  2012 cd
$zcat /usr/share/man/man1/cd.1.gz
.\"
.\"  ........

..........


options with command:

  • -s , search in source directory
  • -m, search in manual page


Example:

$whereis -m ls
ls: /usr/share/man/man1/ls.1.gz
$whereis -s ls
ls: /usr/src/bin/ls
$








whatis


This command gives the brief detail about the other commands/ program in Unix environment.


$whatis ls
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents
git-ls-files(1)          - Show information about files in the index and the working tree
git-ls-remote(1)         - List references in a remote repository
git-ls-tree(1)           - List the contents of a tree object
git-mktree(1)            - Build a tree-object from ls-tree formatted text
mktexlsr(1)              - create ls-R databases

 

option -d with whatis: gives extra debugging information on the screen.


$whatis -d ls
-- Searching PATH for man directories
--   Adding /usr/share/man to manpath
--   Adding /usr/local/man to manpath
-- Adding default manpath entries
--   Adding /usr/share/openssl/man to manpath
-- Parsing config file: /usr/local/etc/man.d/perl5.14.2.conf
--   Adding /usr/local/lib/perl5/5.14.2/man to manpath
--   Adding /usr/local/lib/perl5/5.14.2/perl/man to manpath
-- Using manual path: /usr/share/man:/usr/local/man:/usr/share/openssl/man:/usr/local/lib/perl5/5.14.2/man:/usr/local/lib/perl5/5.14.2/perl/man
-- Available manual locales:
-- Using pager: more -s
-- Found whatis: /usr/share/man/whatis
-- Found whatis: /usr/local/man/whatis
-- Found whatis: /usr/share/openssl/man/whatis
-- Found whatis: /usr/local/lib/perl5/5.14.2/man/whatis
-- Found whatis: /usr/local/lib/perl5/5.14.2/perl/man/whatis
builtin(1), !(1), %(1), .(1), :(1), @(1), [(1), {(1), }(1), alias(1), alloc(1), bg(1), bind(1), bindkey(1), break(1), breaksw(1), builtins(1), case(1), cd(1), chdir(1), command(1), complete(1), continue(1), default(1), dirs(1), do(1), done(1), echo(1), echotc(1), elif(1), else(1), end(1), endif(1), endsw(1), esac(1), eval(1), exec(1), exit(1), export(1), false(1), fc(1), fg(1), filetest(1), fi(1), for(1), foreach(1), getopts(1), glob(1), goto(1), hash(1), hashstat(1), history(1), hup(1), if(1), jobid(1), jobs(1), kill(1), limit(1), local(1), log(1), login(1), logout(1), ls-F(1), nice(1), nohup(1), notify(1), onintr(1), popd(1), printenv(1), printf(1), pushd(1), pwd(1), read(1), readonly(1), rehash(1), repeat(1), return(1), sched(1), set(1), setenv(1), settc(1), setty(1), setvar(1), shift(1), source(1), stop(1), suspend(1), switch(1), telltc(1), test(1), then(1), time(1), times(1), trap(1), true(1), type(1), ulimit(1), umask(1), unalias(1), uncomplete(1), unhash(1), unlimit(1), unset(1), unsetenv(1), until(1), wait(1), where(1), which(1), while(1) - shell built-in commands
ls(1)                    - list directory contents
git-ls-files(1)          - Show information about files in the index and the working tree
git-ls-remote(1)         - List references in a remote repository
git-ls-tree(1)           - List the contents of a tree object
git-mktree(1)            - Build a tree-object from ls-tree formatted text
mktexlsr(1)              - create ls-R databases
$


which

This command locate the program file in user's path

$which ls
/bin/ls
$which chmod
/bin/chmod
$


Options with which:  -s (no output, just return 0 / 1 - if executable is found then it returns 0 else it returns 1)

$which -s ls
$echo $?
0
$



NEXT->


Cracking IT Interview