linux 查找二进制程序、代码等相关文件路径 命令:whereis

Linux 查找二进制程序、代码等相关文件路径 命令whereis

在 Linux 操作系统中,我们经常需要查找某个程序、代码或者其他文件的路径,这时候就可以用到 whereis 命令。

1. 命令语法

whereis [选项] 文件名

2. 命令选项

  • -b:只查找二进制文件。
  • -m:只查找说明文件。
  • -s:只查找源代码文件。

3. 查找二进制文件

如果我们需要查找某个程序的路径,可以使用如下命令:

whereis firefox

执行该命令后,系统会输出如下信息:

firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox /usr/share/man/man1/firefox.1.gz

其中,/usr/bin/firefox 表示程序的可执行文件,/usr/lib/firefox 表示程序的资源文件,/etc/firefox 表示程序的配置文件等。

如果我们只需要查找二进制文件,可以加上选项 -b,如下所示:

whereis -b firefox

执行该命令后,系统会输出如下信息:

firefox: /usr/bin/firefox

这样就只会输出程序的可执行文件路径。

4. 查找代码文件

如果我们需要查找某个程序的源代码文件,可以使用如下命令:

whereis -s firefox

执行该命令后,系统会输出如下信息:

firefox: /usr/src/debug/firefox-91.0.2/firefox-91.0.2 /usr/src/debug/firefox-91.0.2/firefox-91.0.2/obj-x86_64-pc-linux-gnu/dist/include/firefox /usr/src/debug/firefox-91.0.2/firefox-91.0.2/obj-x86_64-pc-linux-gnu/dist/include/firefox/nsprpub /usr/src/debug/firefox-91.0.2/firefox-91.0.2/obj-x86_64-pc-linux-gnu/dist/include/firefox/unstable

其中,/usr/src/debug/firefox-91.0.2/firefox-91.0.2 表示程序的源代码目录。

如果我们只需要查找说明文件,可以加上选项 -m,如下所示:

whereis -m firefox

执行该命令后,系统会输出如下信息:

firefox: /usr/share/man/man1/firefox.1.gz

这样就只会输出程序的说明文件路径。

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容