linux下whereis命令主要用于定位命令所处位置及其联结帮助文件(man)存在位置。

            格式:whereis [-bmsu] [-BMS directory...  -f] filename...

                                        -b:只定位二进制文件(可执行文件)

                                        -m:只定位man文件

                                        -s:只定位源文件

                                        -u:搜索默认路径下除可执行文件,man文件及源文件外的其他文件

                                        -B:指定路径搜索二进制文件(可执行文件)

                                        -M:指定路径搜索man文件

                                        -S:指定路径搜索源文件

                    例子:

                    [root@localhost ~]# whereis ifconfig
                    ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
                    [root@localhost ~]# whereis -b ifconfig
                    ifconfig: /sbin/ifconfig
                    [root@localhost ~]# whereis -s ifconfig
                    ifconfig:
                    [root@localhost ~]# whereis -m ifconfig
                    ifconfig: /usr/share/man/man8/ifconfig.8.gz


which 搜索命令所在位置

                    例子:

                    [root@localhost ~]# which ifconfig
                    /sbin/ifconfig


which与whereis区别:

                    which  搜索的是PATH目录下全部文件

                    whereis 搜索linux数据库中记录的二进制文件,man文件,源文件(默认)

                    locate:查找的是linux数据库中记录的的文件,后接参数即可(若报locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory错误,执行updatedb更新数据库即可,但此操作对linux性能影响极大,望注意。此数据默认由例行工作程序创建crontab创建)

                    find直接查找磁盘