命令名称:locate命令所在路径:/usr/bin/locate执行权限:所有用户功能描述:在文件资料库中查找文件
locate [文件] -i 不区分大小写
yum -y install mlocateupdatedb
1.locate不是实时的,新建的文件可能找不到,需要手动运行命令更新updatedb2.locate无法查找/tmp文件夹下的内容,因为/tmp是临时文件夹,updatedb也不管用
# 搜索文件(区分大小写)locate test.txt# 手动更新文件资料库updatedb# 搜索文件(不区分大小写)locate -i test.txt
命令名称:which命令所在路径:/usr/bin/which执行权限:所有用户功能描述:搜索命令所在目录及别名信息
which ls
# 查找cp命令所在的目录及别名which cp[root@izm5e2q95pbpe1hh0kkwoiz ~]# which cpalias cp='cp -i' /usr/bin/cp# cp的是cp -i的别名# cp命令的目录是/usr/bin/cp[root@izm5e2q95pbpe1hh0kkwoiz ~]# which lsalias ls='ls --color=auto' /usr/bin/ls
命令名称:whereis命令所在路径:/usr/bin/whereis执行权限:所有用户功能描述:搜索命令所在目录及帮助文档路径
whereis ls
# 查找ls命令所在的目录及帮助文档路径whereis ls[root@izm5e2q95pbpe1hh0kkwoiz ~]# whereis lsls: /usr/bin/ls /usr/share/man/man1/ls.1.gz# ls命令所在路径为/usr/bin/ls# ls帮助文档的路径为/usr/share/man/man1/ls.1.gz
命令名称:grep命令所在路径:/bin/grep执行权限:所有用户功能描述:在文件中搜寻字符串匹配的行并输出
grep -v [指定字符串] [文件] -i 不区分大小写(insensitive) -v 排除指定字符串
# 查找target在/etc/inittab文件中(区分大小写)grep target /etc/inittab[root@izm5e2q95pbpe1hh0kkwoiz ~]# grep target /etc/inittab# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target# systemd uses 'targets' instead of runlevels. By default, there are two main targets:# multi-user.target: analogous to runlevel 3# graphical.target: analogous to runlevel 5# To view current default target, run:# To set a default target, run:# systemctl set-default TARGET.target## 查找target在/etc/inittab文件中(不区分大小写)grep -i target /etc/inittab## 在/etc/inittab文件中排除以#号开头的所有行grep -v ^# /etc/inittab
联系客服