搜索命令:
find
locate
whereis
which
type
- linux下最強大的搜索命令為”find“。它的格式為:find <指定目錄> <指定條件> <指定動作>
搜索在根目錄下名字為datagrip.sh文件的所有位置
~$: sudo find / -name 'datagrip.sh'
/opt/DataGrip-2016.3.4/bin/datagrip.sh
/usr/local/DataGrip-2016.3.4/bin/datagrip.sh
- 使用 locate 搜索linux系統(tǒng)中的文件,它比find命令快。因為它查詢的是數(shù)據(jù)庫(/var/lib/locatedb),數(shù)據(jù)庫包含本地所有的文件信息。
~$: sudo locate 'datagrip.sh'
/opt/DataGrip-2016.3.4/bin/datagrip.sh
/usr/local/DataGrip-2016.3.4/bin/datagrip.sh
- 使用 whereis 命令搜索所有可執(zhí)行文件即二進制文件。使用whereis命令搜索grep二進制文件的命令為
~$: whereis grep
grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
- 使用 type 命令查看系統(tǒng)中的某個命令是否為系統(tǒng)自帶的命令。
使用type命令查看cd命令是否為系統(tǒng)自帶的命令;
~$: type cd
cd 是 shell 內(nèi)建
查看grep 是否為系統(tǒng)自帶的命令。
~$: type grep
grep 是 `grep --color=auto' 的別名