在 Linux 中命令搜索命令, 可能大家听的有点绕口, 就是搜搜命令的命令.
首先是 whereis, 我们查看一下 whereis 的手册.
man whereis man 的意思是 manual 手册的意思. man 命令就是查看某个命令的作用以及使用方法.
man whereis
whereis - locate the binary,source,and manual page files for a command
定位一个命令的二进制文件, 源文件, 以及帮助手册.
whereis [options] command
options 中可以包含以下
-b search for binaries. 搜索可执行文件
-m search for manual. 搜索手册
-s search for source 搜索源文件
这三个是常见选项, 够用就行.
如果什么选项都不添加, 则是搜索命令的所在位置以及命令的帮助手册.
例子: whereis ls
输出结果 ls:/bin/ls /usr/share/man/man1/ls.1.gz
例子: whereis -b ls
输出结果 ls:/bin/ls
只是查看命令所在位置
列子: whereis -m ls
输出结果 ls:/usr/share/man/man1/ls.1.gz
查看命令的手册位置.
which 命令也是命令搜索的命令.
它的使用方法 which command
只不过 which 命令只能显示命令的所在位置以及命令的别名.
ps: 谈一下命令的别名. 在 Linux 中执行 alias 这个命令.
alias 就是别名的意思.
会有以下输出结果
- alias egrep='egrep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias grep='grep --color=auto'
- alias l='ls -CF'
- alias la='ls -A'
- alias ll='ls -alF'
- alias ls='ls --color=auto'
格式是 alias command='comand [options]'
就是你在 terminal 中执行 ls 这个条命令, 相当于执行了 ls --color=auto 这条命令. 命令的别名是可以自己修改的.
格式是 alias command='comand [options]'
--color=auto 让命令输出的结果颜色自适应 (就是系统默认的颜色)
来源: http://www.bubuko.com/infodetail-2569636.html