Linux查找命令

1、whereis ---查看命令可执行程序及帮助文档及源码
-b ---查看可执行程序
-m ---查看帮助文档
-s ---查找源码

[root@localhost ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
[root@localhost ~]# 
[root@localhost ~]# whereis -b ls
ls: /usr/bin/ls
[root@localhost ~]# 
[root@localhost ~]# whereis -m ls
ls: /usr/share/man/man1/ls.1.gz
[root@localhost ~]#


2、which 文件名,显示别名及别名对应的原命令,但是查找范围有限(PATH)

[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
	/usr/bin/ls
[root@localhost ~]# export PATH=""
[root@localhost ~]# echo $PATH

[root@localhost ~]# ls
-bash: ls: No such file or directory
[root@localhost ~]# ll
-bash: ls: No such file or directory
[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
[root@localhost ~]# 

 

3、find ---功能强大,查找速度慢,需要全盘扫描
find 范围 表达式
(1)-name ---查找指定名字的文件
# find / -name profile
# find /etc -name fstab

(2)-type ---查找指定类型的文件
# find /root -type l ---在/root下查所有软链接文件
p :管道 s:socket文件 d:目录 l:软链接
f :文本文件

(3)-size ---查找指定大小的文件(K G M 块数 c)
# find / -size 100M ---等于
# find / -size +100M ---大于
                      -100M ---小于
# find / -size +100M -size -200M
---查找大于100M小于200M的文件

(4)-perm ---查看指定权限的文件(数字权限表示法)
# find / -perm 777

(5)-user ---查看指定属主的文件
-group ---查看指定属组的文件
-nouser ---查看没有属主的文件
-nogroup ---查找没有属组的文件
# find / -user aix ---查找属主为aix的所有文件
# find / -user aix -group zu1 ---查看属主为aix属组为zu1的文件
# find / -user aix -o -group zu1 ---或关系

(6)-empty ---查看空文件或空目录
# find /root -empty

(7)-exec 命令 {} \; ---找到指定文件执行exec后的命令
# find /root -name f1 -exec rm -rf {} \;
-ok 命令 {} \; ---找到指定文件执行ok后的命令,并询问
# find /root -name f2 -ok ls -l {} \;

(8)-links 数值 ---查找指定硬链接数的文件

(9)ls -i
-inum i节点编号 ---查看指定i节点编号的文件

posted @ 2021-09-22 17:09  刘铁柱柱柱柱柱柱  阅读(457)  评论(0编辑  收藏  举报