文件搜索命令:locate
<span style="font-size:18px;">[root@localhost /]# locate locate
locate: can not stat () `/var/lib/mlocate/mlocate.db': 没有那个文件或目录
[root@localhost /]# updatedb
[root@localhost /]# locate inittab
/etc/inittab
/usr/share/man/man5/inittab.5.gz
/usr/share/vim/vim72/syntax/inittab.vim
[root@localhost /]# #locate 是去文件目录库里找的 默认这个库是自动更新的 所以新创建的文件目录库里面没有 需要收到调用updatedb 更新库
[root@localhost /]# # 存放在/tmp下的文件不会被收录到目录库里面的
[root@localhost /]# touch /tmp/linshi
[root@localhost /]# updatedb
[root@localhost /]# locate linshi
</span>
文件搜索命令:which
[root@localhost /]# which ls
alias ls='ls --color=auto'
/bin/ls
[root@localhost /]#
文件搜索命令:whereis
[root@localhost /]# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
文件搜索命令:grep
[root@localhost /]# grep multiuser /etc/inittab
# 3 - Full multiuser mode
[root@localhost /]# grep -i multiuser /etc/inittab
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
[root@localhost /]# grep -v # /etc/inittab
用法: grep [选项]... PATTERN [FILE]...
试用‘grep --help’来获得更多信息。
[root@localhost /]# grep -v \# /etc/inittab
id:5:initdefault:
[root@localhost /]# grep -v ^# /etc/inittab
id:5:initdefault:
[root@localhost /]#