参考答案:
whereis
命令是一个用于查找程序二进制文件、源代码文件和帮助文件(手册页等)的 Linux 命令。它可以帮助用户快速定位文件的位置,特别是对于命令、程序和手册页的查找。
1whereis [选项] [文件名]
whereis
查找的是程序的二进制文件、源代码文件和手册页。
例如:1whereis command_name
输出:1whereis ls
该命令会显示1ls: /bin/ls /usr/share/man/man1/ls.1.gz
ls
命令的二进制文件路径和手册页路径。-b
选项来仅查找二进制文件:
例如:1whereis -b command_name
该命令只会返回1whereis -b ls
ls
命令的二进制文件路径(例如 /bin/ls
)。-s
选项来仅查找源代码文件:
例如:1whereis -s command_name
该命令会返回1whereis -s ls
ls
命令的源代码文件路径(如果有的话)。-m
选项来仅查找手册页文件:
例如:1whereis -m command_name
该命令会返回1whereis -m ls
ls
命令的手册页路径(例如 /usr/share/man/man1/ls.1.gz
)。whereis
也可以查找多个文件,多个文件名可以用空格分隔:
例如:1whereis command_name1 command_name2 ...
该命令会同时查找1whereis ls find
ls
和 find
命令的路径。whereis
默认在系统的标准目录中查找文件,但你可以通过环境变量调整查找路径。使用 -f
选项来指定查找的目录:
1whereis -f /path/to/directory command_name
1whereis --config filename
查找 ls
命令的路径:
1whereis ls
输出:
1ls: /bin/ls /usr/share/man/man1/ls.1.gz
这里返回的是 ls
命令的二进制文件路径和手册页路径。
查找 gcc
命令的二进制文件:
1whereis -b gcc
输出:
1gcc: /usr/bin/gcc
只返回 gcc
的二进制文件路径。
查找 bash
命令的源代码:
1whereis -s bash
输出:
1bash: /usr/src/bash-4.4
返回 bash
源代码的位置(如果有的话)。
查找 vim
的手册页:
1whereis -m vim
输出:
1vim: /usr/share/man/man1/vim.1.gz
仅返回 vim
命令的手册页路径。
最近更新时间:2024-12-24