Linux系統之whereis命令的基本使用

Linux系統之whereis命令的基本使用

  • 一、whereis命令介紹
  • 二、whereis命令的使用幫助
    • 2.1 whereis命令的幫助信息
    • 2.2 whereis命令幫助解釋
  • 三、whereis命令的基本使用
    • 3.1 查找命令的位置
    • 3.2 僅查找二進制文件
    • 3.3 僅查找手冊頁
    • 3.4 輸出實際使用的查找路徑
    • 3.5 指定自定義搜索路徑
  • 四、注意事項

在這里插入圖片描述

一、whereis命令介紹

whereis 命令在 Linux 系統中用于查找二進制文件、源代碼文件和幫助手冊頁的位置。它主要搜索標準的可執行文件路徑、特定配置文件路徑以及手冊頁路徑,對于定位系統命令或工具非常有用。

二、whereis命令的使用幫助

2.1 whereis命令的幫助信息

在命令行終端中,我們使用-h選項查詢whereis命令的基本幫助信息。

[root@openEuler ~]# whereis  -hUsage:whereis [options] [-BMS <dir>... -f] <name>Locate the binary, source, and manual-page files for a command.Options:-b         search only for binaries-B <dirs>  define binaries lookup path-m         search only for manuals and infos-M <dirs>  define man and info lookup path-s         search only for sources-S <dirs>  define sources lookup path-f         terminate <dirs> argument list-u         search for unusual entries-g         interpret name as glob (pathnames pattern)-l         output effective lookup paths-h, --help     display this help-V, --version  display versionFor more details see whereis(1).

2.2 whereis命令幫助解釋

用法:

whereis [選項] [-BMS <目錄>... -f] <名稱>

命令功能:

  • 查找命令的二進制文件、源文件和手冊頁文件的位置。

選項說明:

  • -b:僅查找二進制文件。
  • -B <目錄>:指定查找二進制文件的路徑。
  • -m:僅查找手冊頁和信息文件。
  • -M <目錄>:指定查找手冊頁和信息文件的路徑。
  • -s:僅查找源代碼文件。
  • -S <目錄>:指定查找源代碼文件的路徑。
  • -f:表示目錄參數列表的結束。
  • -u:查找不符合常規的條目,即那些沒有對應的二進制文件、手冊頁或源文件的項目。
  • -g:將名稱解釋為路徑名模式(globbing pattern)。
  • -l:輸出實際使用的查找路徑。

幫助和版本信息:

  • -h, --help:顯示幫助信息。
  • -V, --version:顯示版本信息。

三、whereis命令的基本使用

3.1 查找命令的位置

查找 httpd的位置,包括其二進制文件、源碼文件和手冊頁。

[root@openEuler ~]# whereis httpd
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd /usr/share/man/man8/httpd.8.gz

3.2 僅查找二進制文件

可以使用 -b 選項,僅查找二進制文件。

[root@openEuler ~]# whereis -b httpd
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd

3.3 僅查找手冊頁

可以使用 -m 選項,查看httpd的手冊頁。

[root@openEuler ~]# whereis -m httpd
httpd: /usr/share/man/man8/httpd.8.gz

3.4 輸出實際使用的查找路徑

使用-l選項,輸出實際使用的查找路徑,如下所示:

[root@openEuler ~]# whereis -l
bin: /usr/bin
bin: /usr/sbin
bin: /usr/lib
bin: /usr/lib64
bin: /etc
bin: /usr/games
bin: /usr/local/bin
bin: /usr/local/sbin
bin: /usr/local/etc
bin: /usr/local/lib
bin: /usr/local/games
bin: /usr/include
bin: /usr/local
bin: /usr/libexec
bin: /usr/share
bin: /opt/containerd/bin
man: /usr/share/man/es
man: /usr/share/man/man0p
man: /usr/share/man/zh_CN
man: /usr/share/man/da
man: /usr/share/man/man9
man: /usr/share/man/man4x
man: /usr/share/man/man3
man: /usr/share/man/man5x
man: /usr/share/man/man6x
man: /usr/share/man/pt
man: /usr/share/man/man6
man: /usr/share/man/mann
man: /usr/share/man/tr.UTF-8
man: /usr/share/man/man7x
man: /usr/share/man/it
man: /usr/share/man/man7
man: /usr/share/man/cs
man: /usr/share/man/man8
man: /usr/share/man/man1x
man: /usr/share/man/nl
man: /usr/share/man/tr
man: /usr/share/man/uk
man: /usr/share/man/man8x
man: /usr/share/man/ru
man: /usr/share/man/sv
man: /usr/share/man/pl
man: /usr/share/man/man3p
man: /usr/share/man/man2
man: /usr/share/man/man4
man: /usr/share/man/tr.ISO8859-9
man: /usr/share/man/id
man: /usr/share/man/man1p
man: /usr/share/man/sr
man: /usr/share/man/ja
man: /usr/share/man/man2x
man: /usr/share/man/man5
man: /usr/share/man/ro
man: /usr/share/man/man9x
man: /usr/share/man/de
man: /usr/share/man/sk
man: /usr/share/man/ko
man: /usr/share/man/man3x
man: /usr/share/man/pt_BR
man: /usr/share/man/fr
man: /usr/share/man/ca
man: /usr/share/man/man1
man: /usr/share/info
src: /usr/src/debug
src: /usr/src/kernels

3.5 指定自定義搜索路徑

如果有特定的路徑想要搜索,可以使用 -B, -M, 或 -S 來定義這些路徑。例如,要在一個非標準目錄/root/node-v14.17.0-linux-x64/bin 中查找node 的二進制文件:

[root@openEuler ~]# whereis -B /root/node-v14.17.0-linux-x64/bin  -b node
node: /root/node-v14.17.0-linux-x64/bin/node

四、注意事項

  1. 使用 -b, -m, 或 -s 選項可分別限制搜索僅限于二進制文件、手冊頁或源代碼文件。
  2. 如果要查找非標準位置的文件,請結合 -B, -M, 或 -S 選項自定義搜索路徑。
  3. 當命令未找到預期的結果時,可能是因為程序不是從標準路徑安裝的,考慮使用 findlocate 命令代替。
  4. 使用 -u 選項可以幫助發現那些缺少了通常應關聯的文件(如手冊頁或二進制)的不尋常條目。
  5. 對于有多個版本或同名但不同用途的命令,whereis 可能會列出所有匹配項,注意甄別所需的具體路徑。
  6. 記住 whereis 不會搜索 $PATH 環境變量中定義的所有路徑,它有一套自己的默認搜索路徑。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/894605.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/894605.shtml
英文地址,請注明出處:http://en.pswp.cn/news/894605.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Autosar-以太網是怎么運行的?(Davinci配置部分)

寫在前面&#xff1a; 入行一段時間了&#xff0c;基于個人理解整理一些東西&#xff0c;如有錯誤&#xff0c;歡迎各位大佬評論區指正&#xff01;&#xff01;&#xff01; 目錄 1.Autosar ETH通訊軟件架構 2.Ethernet MCAL配置 2.1配置對應Pin屬性 2.2配置TXD引腳 2.3配…

2024年度總結

首先&#xff0c;我是在2023年結束高中生涯進入大學的&#xff0c;難免會有固化的“高中生”思維&#xff0c;我等著老師的安排&#xff0c;看著課表上課&#xff0c;跟著時間吃飯&#xff0c;睡覺&#xff0c;偶爾會熬夜&#xff0c;但整體跟高中沒差太多。我對社團沒興趣&…

【Block總結】CSAM,包含分割、關鍵點、切分等均適用!|即插即用

論文信息 標題: CSAM: A 2.5D Cross-Slice Attention Module for Anisotropic Volumetric Medical Image Segmentation 論文鏈接: https://arxiv.org/pdf/2311.04942 GitHub鏈接: https://github.com/aL3x-O-o-Hung/CSAM 創新點 CSAM&#xff08;跨切片注意力模塊&#xff…

解決PyG安裝中torch-sparse安裝失敗問題:詳細指南

1 問題描述 最近在學習GNN&#xff0c;需要使用PyTorch Geometric&#xff08;PyG&#xff09;庫。在安裝PyG的過程中&#xff0c;遇到了torch-sparse安裝失敗的問題&#xff0c;錯誤提示為&#xff1a; ERROR: Failed building wheel for torch-sparse本文將詳細記錄問題的解…

鳥哥Linux私房菜筆記(三)

鳥哥Linux私房菜筆記&#xff08;三&#xff09; 該第三部分和第四部分主要為原書的第十一章&#xff08;正則表達式與文件格式化處理&#xff09;&#xff0c;第十二章學習shell腳本&#xff0c;第十六章&#xff08;進程管理與SElinux初探部分&#xff09;&#xff0c;第十七…

學習日記-250203

一.論文 看師兄寫好的一稿。 二、計劃&#xff1a; 繼續看論文里的問題。 然后繼續看promptCD相關&#xff0c;明天要看論文啦,今天家里有些事比較忙&#xff08;碎碎念&#xff09; 三. &#xff09;——&#xff08; 注冊了 openreview,ORCID,Google scholar&…

python學opencv|讀取圖像(五十四)使用cv2.blur()函數實現圖像像素均值處理

【1】引言 前序學習進程中&#xff0c;對圖像的操作均基于各個像素點上的BGR值不同而展開。 對于彩色圖像&#xff0c;每個像素點上的BGR值為三個整數&#xff0c;因為是三通道圖像&#xff1b;對于灰度圖像&#xff0c;各個像素上的BGR值是一個整數&#xff0c;因為這是單通…

Kafka ACL(訪問控制列表)介紹

文章目錄 Kafka ACL&#xff08;訪問控制列表&#xff09;介紹1. Kafka ACL 的基本概念1.1 Kafka ACL 的目標1.2 Kafka ACL 的組成部分 2. Kafka 支持的資源類型2.1 Topic&#xff08;主題&#xff09;2.2 Consumer Group&#xff08;消費者組&#xff09;2.3 Cluster&#xff…

在 WSL2 中重啟 Ubuntu 實例

在 WSL2 中重啟 Ubuntu 實例&#xff0c;可以按照以下步驟操作&#xff1a; 方法 1: 使用 wsl 命令 關閉 Ubuntu 實例: 打開 PowerShell 或命令提示符&#xff0c;運行以下命令&#xff1a; wsl --shutdown這會關閉所有 WSL2 實例。 重新啟動 Ubuntu: 再次打開 Ubuntu&#x…

Spring Boot 2 快速教程:WebFlux處理流程(五)

WebFlux請求處理流程 下面是spring mvc的請求處理流程 具體步驟&#xff1a; 第一步&#xff1a;發起請求到前端控制器(DispatcherServlet) 第二步&#xff1a;前端控制器請求HandlerMapping查找 Handler &#xff08;可以根據xml配置、注解進行查找&#xff09; 匹配條件包括…

小程序設計和開發:如何研究同類型小程序的優點和不足。

一、確定研究目標和范圍 明確研究目的 在開始研究同類型小程序之前&#xff0c;首先需要明確研究的目的。是為了改進自己的小程序設計和開發&#xff0c;還是為了了解市場趨勢和用戶需求&#xff1f;不同的研究目的會影響研究的方法和重點。例如&#xff0c;如果研究目的是為了…

使用 Numpy 自定義數據集,使用pytorch框架實現邏輯回歸并保存模型,然后保存模型后再加載模型進行預測,對預測結果計算精確度和召回率及F1分數

1. 導入必要的庫 首先&#xff0c;導入我們需要的庫&#xff1a;Numpy、Pytorch 和相關工具包。 import numpy as np import torch import torch.nn as nn import torch.optim as optim from sklearn.metrics import accuracy_score, recall_score, f1_score2. 自定義數據集 …

Unity-編譯構建Android的問題記錄

文章目錄 報錯&#xff1a;AAPT2 aapt2-4.1.2-6503028-osx Daemon #0 Failed to shutdown within timeout報錯信息解讀&#xff1a;原因分析最終處理方法 報錯&#xff1a;AAPT2 aapt2-4.1.2-6503028-osx Daemon #0 Failed to shutdown within timeout 報錯信息解讀&#xff1…

【axios二次封裝】

axios二次封裝 安裝封裝使用 安裝 pnpm add axios封裝 // 進行axios二次封裝&#xff1a;使用請求與響應攔截器 import axios from axios import { ElMessage } from element-plus//創建axios實例 const request axios.create({baseURL: import.meta.env.VITE_APP_BASE_API,…

SQL進階實戰技巧:如何構建用戶行為轉移概率矩陣,深入洞察會話內活動流轉?

目錄 1 場景描述 1.1 用戶行為轉移概率矩陣概念 1.2 用戶行為轉移概率矩陣構建方法 (1) 數據收集

Vue3.0實戰:大數據平臺可視化(附完整項目源碼)

文章目錄 創建vue3.0項目項目初始化項目分辨率響應式設置項目頂部信息條創建頁面主體創建全局引入echarts和axios后臺接口創建express銷售總量圖實現完整項目下載項目任何問題都可在評論區,或者直接私信即可。 創建vue3.0項目 創建項目: vue create vueecharts選擇第三項:…

Java自定義IO密集型和CPU密集型線程池

文章目錄 前言線程池各類場景描述常見場景案例設計思路公共類自定義工廠類-MyThreadFactory自定義拒絕策略-RejectedExecutionHandlerFactory自定義阻塞隊列-TaskQueue&#xff08;實現 核心線程->最大線程數->隊列&#xff09; 場景1&#xff1a;CPU密集型場景思路&…

【VM】VirtualBox安裝ubuntu22.04虛擬機

閱讀本文之前&#xff0c;請先根據 安裝virtualbox 教程安裝virtulbox虛擬機軟件。 1.下載Ubuntu系統鏡像 打開阿里云的鏡像站點&#xff1a;https://developer.aliyun.com/mirror/ 找到如圖所示位置&#xff0c;選擇Ubuntu 22.04.3(destop-amd64)系統 Ubuntu 22.04.3(desto…

Pandas基礎08(分箱操作/時間序列/畫圖)

3.8.1 Pandas分箱操作 數據分箱&#xff08;Binning&#xff09; 是一種數據預處理方法&#xff0c;用于將連續型變量的數值范圍分割成若干個區間或“箱”&#xff08;bins&#xff09;&#xff0c;將數據按照這些區間進行分類&#xff0c;從而轉換為離散型變量。這種方法常用…

C#,shell32 + 調用控制面板項(.Cpl)實現“新建快捷方式對話框”(全網首發)

Made By 于子軒&#xff0c;2025.2.2 不管是使用System.IO命名空間下的File類來創建快捷方式文件&#xff0c;或是使用Windows Script Host對象創建快捷方式&#xff0c;亦或是使用Shell32對象創建快捷方式&#xff0c;都對用戶很不友好&#xff0c;今天小編為大家帶來一種全新…