Linux命令之定位与查找

apropos

apropos用于查找你所需要的命令。当你不能确切的记住一个命令时,可以通过apropos模糊查找,找出所有相关的命令,然后,你就可以从中找出你所需要的命令了。再通过man或者info命令,就可以获取该命令的详细信息了。

 

NAME
       apropos - search the whatis database for strings

SYNOPSIS
       apropos keyword ...

DESCRIPTION
       apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.

 

whatis

whatis命令用于输出一个命令的简单描述。

 

NAME
       whatis - search the whatis database for complete words.

SYNOPSIS
       whatis keyword ...

DESCRIPTION
       whatis  searches a set of database files containing short descriptions of system commands for keywords and displays the result on the  standard  output.   Only  complete word matches are displayed.

 

which

which用于定位一个shell命令所在的完整路径。

 

NAME
       which - shows the full path of (shell) commands.

SYNOPSIS
       which [options] [--] programname [...]

DESCRIPTION
       Which takes one or more arguments. For each of its arguments it prints to stdout the  full path of the executables that would have been executed when this argument had
       been entered at the shell prompt. It does this by searching for an executable or  script in the directories listed in the environment variable PATH using the same      algorithm as bash(1).

 

locate

locate命令可以通过名称查找文件。名称可以是正则表达式。find也可以达到这样的查找效果,由于find比较重要,故在其他的博文中给出单独的解释。

 

NAME
       locate - find files by name

SYNOPSIS
       locate [OPTION]... PATTERN...

DESCRIPTION
       locate  reads  one  or  more  databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line.

       PATTERNs can contains globbing characters.  If any PATTERN contains no globbing characters, locate behaves as if the pattern were *PATTERN*.

       By default, locate does not check whether files found in database still exist; locate can never report files created after the most recent update of the relevant database.

 

whereis

whereis命令用于搜索指定程序的二进制、源码、man手册的位置。对于一般的使用,根本用不到下面提到的各个选项。只需要执行whereis cmd即可。

 

NAME
       whereis - locate the binary, source, and manual page files for a command

SYNOPSIS
       whereis [ -bmsu ] [ -BMS directory...  -f ] filename ...

DESCRIPTION
       whereis locates source/binary and manuals sections for specified files.  The supplied names are first stripped of leading pathname components  and  any  (single)  trailing
       extension  of  the form .ext, for example, .c.  Prefixes of s.  resulting from use of source code control are also dealt with.  whereis then attempts to locate the desired      program in a list of standard Linux places.

OPTIONS
       -b     Search only for binaries.

       -m     Search only for manual sections.

       -s     Search only for sources.      

       -u     Search  for unusual entries.  A file is said to be unusual if it does not have one entry of each requested type.  Thus ‘whereis  -m  -u  *’  asks  for  those  files in the current directory which have no documentation.

       -B     Change or otherwise limit the places where whereis searches for binaries.

       -M     Change  or  otherwise  limit the places where whereis searches for manual sec-
              tions.

       -S     Change or otherwise limit the places where whereis searches for sources.

       -f     Terminate the last directory list and signals the start  of  file  names,  and must be used when any of the -B, -M, or -S options are used.

 

例子

 shell测试脚本

echo "apropos tcpdump"
apropos tcpdump
echo "whatis tcpdump"
whatis tcpdump
echo "which tcpdump"
which tcpdump
echo "locate tcpdump"
locate tcpdump
echo "whereis tcpdump"
whereis tcpdump
echo "apropos tcp"
apropos tcp
echo "locate tcp"
locate tcp

执行shell脚本,得测试结果,如下
apropos tcpdump
tcpdump              (8)  - dump traffic on a network
tcpdump             (rpm) - A network traffic monitoring tool.
tcpslice             (8)  - extract pieces of and/or glue together tcpdump files
whatis tcpdump
tcpdump              (8)  - dump traffic on a network
tcpdump             (rpm) - A network traffic monitoring tool.
which tcpdump
/usr/sbin/tcpdump
locate tcpdump
/usr/sbin/tcpdump
/usr/share/doc/tcpdump-3.9.4
/usr/share/doc/tcpdump-3.9.4/CHANGES
/usr/share/doc/tcpdump-3.9.4/LICENSE
/usr/share/doc/tcpdump-3.9.4/README
/usr/share/man/man8/tcpdump.8.gz
whereis tcpdump
tcpdump: /usr/sbin/tcpdump /usr/share/man/man8/tcpdump.8.gz
apropos tcp
clock_getcpuclockid  (3p)  - access a process CPU-time clock (ADVANCED REALTIME)
nc                   (1)  - arbitrary TCP and UDP connections and listens
nc                  (rpm) - Reads and writes data across network connections using TCP or UDP.
netinet/tcp.h [tcp]  (0p)  - definitions for the Internet Transmission Control Protocol (TCP)
nmblookup            (1)  - NetBIOS over TCP/IP client used to lookup NetBIOS names
pthread_getcpuclockid (3p)  - access a thread CPU-time clock (ADVANCED REALTIME THREADS)
stapprobes.tcp [stapprobes] (3stap)  - systemtap tcp probe points
tcp                  (7)  - TCP protocol
tcp.disconnect [tcp] (3stap)  - TCP socket disconnection
tcp.disconnect.return [tcp] (3stap)  - TCP socket disconnection complete
tcp.receive [tcp]    (3stap)  - Called when a TCP packet is received
tcp.recvmsg [tcp]    (3stap)  - Receiving TCP message
tcp.recvmsg.return [tcp] (3stap)  - Receiving TCP message complete
tcp.sendmsg [tcp]    (3stap)  - Sending a tcp message
tcp.sendmsg.return [tcp] (3stap)  - Sending TCP message is done
tcp.setsockopt [tcp] (3stap)  - Call to setsockopt
tcp.setsockopt.return [tcp] (3stap)  - Return from setsockopt
tcp_wrappers        (rpm) - A security tool which acts as a wrapper for TCP daemons.
tcpd                 (8)  - access control facility for internet services
tcpdump              (8)  - dump traffic on a network
tcpdump             (rpm) - A network traffic monitoring tool.
tcpslice             (8)  - extract pieces of and/or glue together tcpdump files
locate tcp
/bin/tcptraceroute
/lib/modules/2.6.18-194.el5/kernel/drivers/atm/atmtcp.ko
/lib/modules/2.6.18-194.el5/kernel/drivers/scsi/iscsi_tcp.ko
/lib/modules/2.6.18-194.el5/kernel/drivers/scsi/libiscsi_tcp.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_cubic.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_diag.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_highspeed.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_htcp.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_hybla.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_lp.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_scalable.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_vegas.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_veno.ko
/lib/modules/2.6.18-194.el5/kernel/net/ipv4/tcp_westwood.ko
/lib/modules/2.6.18-194.el5/kernel/net/netfilter/xt_tcpmss.ko
/lib/modules/2.6.18-194.el5/kernel/net/netfilter/xt_tcpudp.ko
/lib64/iptables/libip6t_tcp.so
/lib64/iptables/libipt_tcp.so
/lib64/iptables/libipt_tcpmss.so
/usr/include/tcpd.h
/usr/include/linux/atm_tcp.h
/usr/include/linux/tcp.h
/usr/include/linux/netfilter/nf_conntrack_tcp.h
/usr/include/linux/netfilter/xt_tcpmss.h
/usr/include/linux/netfilter/xt_tcpudp.h
/usr/include/linux/netfilter_ipv4/ip_conntrack_tcp.h
/usr/include/linux/netfilter_ipv4/ipt_tcpmss.h
/usr/include/netinet/tcp.h
/usr/include/xulrunner-sdk-1.9/system_wrappers/netinet/tcp.h
/usr/lib/gstreamer-0.10/libgsttcp.so
/usr/lib64/gstreamer-0.10/libgsttcp.so
/usr/lib64/python2.4/encodings/ptcp154.py
/usr/lib64/python2.4/encodings/ptcp154.pyc
/usr/lib64/python2.4/encodings/ptcp154.pyo
/usr/local/Python2.7/lib/python2.7/encodings/ptcp154.py
/usr/local/Python2.7/lib/python2.7/encodings/ptcp154.pyc
/usr/local/Python2.7/lib/python2.7/encodings/ptcp154.pyo
/usr/sbin/tcpd
/usr/sbin/tcpdump
/usr/sbin/tcpslice
/usr/share/doc/tcp_wrappers-7.6
/usr/share/doc/tcpdump-3.9.4
/usr/share/doc/isdn4k-utils-3.2/_howto/tcpip_stack_ms.txt
/usr/share/doc/selinux-policy-2.4.6/html/services_tcpd.html
/usr/share/doc/selinux-policy-2.4.6/html/services_ucspitcp.html
/usr/share/doc/tcp_wrappers-7.6/BLURB
/usr/share/doc/tcp_wrappers-7.6/Banners.Makefile
/usr/share/doc/tcp_wrappers-7.6/CHANGES
/usr/share/doc/tcp_wrappers-7.6/DISCLAIMER
/usr/share/doc/tcp_wrappers-7.6/README
/usr/share/doc/tcp_wrappers-7.6/README.IRIX
/usr/share/doc/tcp_wrappers-7.6/README.NIS
/usr/share/doc/tcpdump-3.9.4/CHANGES
/usr/sbin/tcpslice
/usr/share/doc/tcp_wrappers-7.6
/usr/share/doc/tcpdump-3.9.4
/usr/share/doc/isdn4k-utils-3.2/_howto/tcpip_stack_ms.txt
/usr/share/doc/selinux-policy-2.4.6/html/services_tcpd.html
/usr/share/doc/selinux-policy-2.4.6/html/services_ucspitcp.html
/usr/share/doc/tcp_wrappers-7.6/BLURB
/usr/share/doc/tcp_wrappers-7.6/Banners.Makefile
/usr/share/doc/tcp_wrappers-7.6/CHANGES
/usr/share/doc/tcp_wrappers-7.6/DISCLAIMER
/usr/share/doc/tcp_wrappers-7.6/README
/usr/share/doc/tcp_wrappers-7.6/README.IRIX
/usr/share/doc/tcp_wrappers-7.6/README.NIS
/usr/share/doc/tcpdump-3.9.4/CHANGES
/usr/share/doc/tcpdump-3.9.4/LICENSE
/usr/share/doc/tcpdump-3.9.4/README
/usr/share/man/man0p/tcp.h.0p.gz
/usr/share/man/man3/clnttcp_create.3.gz
/usr/share/man/man3/stapprobes.tcp.3stap.gz
/usr/share/man/man3/svctcp_create.3.gz
/usr/share/man/man3/tcp.disconnect.3stap.gz
/usr/share/man/man3/tcp.disconnect.return.3stap.gz
/usr/share/man/man3/tcp.receive.3stap.gz
/usr/share/man/man3/tcp.recvmsg.3stap.gz
/usr/share/man/man3/tcp.recvmsg.return.3stap.gz
/usr/share/man/man3/tcp.sendmsg.3stap.gz
/usr/share/man/man3/tcp.sendmsg.return.3stap.gz
/usr/share/man/man3/tcp.setsockopt.3stap.gz
/usr/share/man/man3/tcp.setsockopt.return.3stap.gz
/usr/share/man/man3p/clock_getcpuclockid.3p.gz
/usr/share/man/man3p/pthread_getcpuclockid.3p.gz
/usr/share/man/man7/tcp.7.gz
/usr/share/man/man8/tcpd.8.gz
/usr/share/man/man8/tcpdump.8.gz
/usr/share/man/man8/tcpslice.8.gz
/usr/share/system-config-network/netconfpkg/gui/sharedtcpip.glade
/usr/share/system-config-network/netconfpkg/gui/sharedtcpip.py
/usr/share/system-config-network/netconfpkg/gui/sharedtcpip.pyc
/usr/share/system-config-network/netconfpkg/gui/sharedtcpip.pyo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值