Linux系统配置及服务管理_文件查找

一、文件查找
1.which :命令查找

[root@localhost ~]# 
[root@localhost ~]# which ls
alias ls='ls --color=auto'
	/usr/bin/ls
[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
	/usr/bin/ls
[root@localhost ~]# which cat
/usr/bin/cat
[root@localhost ~]# which find
/usr/bin/find
[root@localhost ~]# 

2.find: 文件查找,针对文件名
3.locate:文件查找,依赖数据库
*查找任意文件(find命令)
语法:find [path…] [options] [expression] [action]
命令 路径 选项 表达式 动作
1.按文件名字查找

[root@localhost ~]# find /etc -name "hosts"
/etc/hosts
[root@localhost ~]# find /etc -iname "HoSts"
/etc/hosts
[root@localhost ~]# find /etc -name "hos*"
/etc/selinux/targeted/active/modules/100/hostname
/etc/host.conf
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/hostname
[root@localhost ~]# 

-i忽略大小写
2.按文件大小:

[root@localhost ~]# find /etc -size  +5M
/etc/udev/hwdb.bin
[root@localhost ~]# find /etc -size  =5M
find: Invalid argument `=5M' to -size
[root@localhost ~]# 

文件大于5M,用+5M ,小于5M用-5M
3.指定查找的目录深度:

[root@localhost ~]# find / -maxdepth 4 -a -name "ifcfg-en*"
/etc/sysconfig/network-scripts/ifcfg-ens33

[root@localhost ~]# find / -maxdepth 4 -a -name "ifcfg-en*"
/etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost ~]# find / -maxdepth 3 -a -name "ifcfg-en*"
[root@localhost ~]# find / -maxdepth 3 -a -name "ifcfg-en*"
`
ifcfg-en在第四层目录,在第三层是查不到的
4按文件属主、属组找:

```powershell
[root@localhost ~]#  find      /home     -user       jack
/home/jack
/home/jack/.bash_logout
/home/jack/.bash_profile
/home/jack/.bashrc
/home/jack/1.txt
/home/jack/2.txt
/home/jack/3.txt
/home/jack/4.txt
/home/jack/5.txt
/home/jack/.bash_history
[root@localhost ~]# 

属主

[root@localhost ~]#  find      /home     -user       jack
/home/jack
/home/jack/.bash_logout
/home/jack/.bash_profile
/home/jack/.bashrc
/home/jack/1.txt
/home/jack/2.txt
/home/jack/3.txt
/home/jack/4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值