linux下whereis,which學習區分

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直接查找磁盤


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章