hi 感恩节——Linux基础教程之mysql和php

2019-09-23 09:21:10于丽

--工作原理:

在后台数据库按文件名搜索

所以,新创建的文件往往搜索不到(缺点)

解决办法:等(1天);updatedb命令更新数据库

--缺点:

只能按照文件名搜索(功能弱)——理解就是,牺牲功能提升速度

--搜索/更新配置:

vi /etc/updatedb.conf

得到

PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/cache/ccache /var/spool/cups /var/spool/squid /var/tmp"

第一行就是说,是否执行下列的更新规则

后面是不搜索这些文件夹/文件

所以有时候有些目录中的内容搜索不到的——比如常用的/tmp

3.2 命令搜索命令whereis和which

3.2.1 whereis

--基本

[root@andy ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

能搜索到命令的目录以及其帮助文档的目录(所以命令所在位置where is ,同时要牢记,linux中一切皆文件)

--选项

-b 只查找可执行文件

-m 只查找帮助文件

[root@andy ~]# whereis -b mkdir
mkdir: /bin/mkdir

3.2.2 which

--基本

[root@andy ~]# which ls
alias ls='ls --color=auto'
/bin/ls

还会查到别名(如果有的话)。

这里ls会自动显示不同的颜色

[root@andy ~]# which pwd
/bin/pwd

没有别名就还是这样,但没有帮助文档

3.2.3 其他说明

--找不到的命令

[root@andy ~]# which cd
/usr/bin/which: no cd in (/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@andy ~]# where cd
-bash: where: command not found

有些类型是找不到的,原因是shell自带的(以后学)

--path环境变量

环境设定的基本路径,比如上述(/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

它使我们可以不用绝对路径来输入命令——windows也是这样的

还是那句话,都是文件

path环境变量的定义:系统搜索命令的路径

自己写的程序,要么命令都写绝对路径,要么放在这些path路径中

3.3 find命令

最强大的搜索命令——这里只学习基本的、常用的用法

--基本

find [搜索范围] [搜索条件] 文件名

[root@andy ~]# find / -name install.log
/root/install.log

会发现速度很慢——范围太大

而且真实情况会更加复杂,有可能速度更慢,压力更大