find命令及

1.查找命令
which 通过PATH环境变量查找可执行文件
whereis 通过文件环境变量查找,比whic范围大一些
locate 通过索引数据库查找文件,centos7下要安装mlocate
find 通过直接搜索硬盘查找,功能强大

参数作用
-name:按照名字查找
-perm:安装权限查找
-prune:不再当前指定的目录下查找
-user:文件属主来查找
-nogroup:文件所属组来查找
-nouser:查找无有效所属组的文件
-type:按照文件类型查找

按时间查找
-atime n :将 n24 小时内存取过的的文件列出来
-ctime n :将 n
24 小时内改变、新增的文件或者目录列出来
-mtime n :将 n*24 小时内修改过的文件或者目录列出来

按名称查找

[root@localhost ~]# find /etc/ -name 'audit*'
/etc/systemd/system/multi-user.target.wants/auditd.service
/etc/selinux/targeted/active/modules/100/auditadm
/etc/audit
/etc/audit/audit-stop.rules
/etc/audit/auditd.conf
/etc/audit/rules.d/audit.rules
/etc/audit/audit.rules

根据文件从属关系查找
find . -user root 查找属主指定用户的所有文件

[root@localhost ~]# find . -user root
.
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./anaconda-ks.cfg
./.bash_history

find . -group root 查找属组指定用户的所有文件

[root@localhost ~]# find . -group root
.
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./anaconda-ks.cfg
./.bash_history

find . -uid 0 查找属主指定的UID的所有文件

[root@localhost ~]# find . -uid 0
.
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./anaconda-ks.cfg
./.bash_history

find . -gid 0 查找属组指定的UID的所有文件

[root@localhost ~]# find . -gid 0
.
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./anaconda-ks.cfg
./.bash_history

根据文件类型查找

类型作用
f普通文件
d目录文件
l符号链接文件
b块设备文件
c字符设备文件
p管道文件
s套接字文件

find . -type f 查找当前目录的普通文件

[root@localhost home]# find . -type f
./cmd/.bash_logout
./cmd/.bash_profile
./cmd/.bashrc
./qaz/.bash_logout
./qaz/.bash_profile
./qaz/.bashrc

find . -type d 查找当前目录下的目录文件

[root@localhost home]# find . -type d
.
./cmd
./qaz
./jack
./zhuzhu
./maomao100

根据文件的大小查找(常用的单位k,m,G)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值