linux基础(15)--locate、find命令的使用--RHEL6.5
来源:互联网 发布:endnote mac 编辑:程序博客网 时间:2024/05/18 20:07
本文涉及命令: locate find
1. locate
定位指定文件的位置。
使用locate前建议先更新一下数据库,updatedb, 虽然此数据库会自动进行更新,但是在每晚的2:00进行,因此更新之后下次更新之前新增的文件使用locate时无法定位到的。
updatedb
locate passwd
2. find
查找文件,可通过对此命令的查找条件进行各种组合查询出符合自己需要的文件位置。
(1)根据用户和组查找
find /home -user user1
find /home -group group1
(2)根据文件类型查找
f 文件, d 目录, l 连接, p 管道,c 字符文件,b 块文件 ,s socket文件
find /home -type f
find /home -type d
(3)根据名字查找
find /home -name "file1"
(4)根据大小查找
大于2M
find /home -size +2M
小于2M
find /home -size -2M
以M为单位显示文件信息
ll -h /home
(4)根据时间查找
ctime:change time, 如文件属性
mtime:modify time, 文件内容被修改
atime:access time, 文件被读过
ll 默认列出的是文件的mtime。
列出文件的atime:
ls -lu /home
列出文件的ctime:
ls -lc /home
列出文件的mtime:
ls -l /home
(5)根据文件权限查找
权限等于755的文件
find /home -perm 755
权限至少为755的文件:
find /home -perm -755
(6)查找目录的深度
find /home -maxdepth 1
find /home -maxdepth 2
(7)多条件查找
a -and
o -or
! -not
在/home下权限至少为002的文件:
find /home -type f -a -perm -002
(8)-exec
接后续命令
删除/root下的普通文件:
find /home -type f -exec rm -f {} \;
- linux基础(15)--locate、find命令的使用--RHEL6.5
- locate、find命令使用总结
- linux的locate命令和find命令的区别
- linux 下find、locate、whereis、which以及type命令使用
- linux分享之locate、find命令使用总结
- Linux内、外部命令的使用、文件权限、文件查找(find、locate、grep)
- Linux内、外部命令的使用、文件权限、文件查找(find、locate、grep)
- Linux下which、whereis、locate、find命令的使用和区别
- linux下查找命令的使用:find、locate、whereis、grep、which
- linux中命令 which/whereis/locate/find 的使用总结(总结+转载)
- Linux locate命令 和 Linux find命令
- Linux的五个查找命令:find,locate,whereis,which,type
- Linux的五个查找命令:find,locate,whereis,which,type
- Linux的五个查找命令:find,locate,whereis,which,type
- linux下which、whereis、locate、find 命令的区别
- linux的五个查找命令find,locate,whereis,which,type
- Linux的五个查找命令:find,locate,whereis,which,type
- Linux的五个查找命令:find,locate,whereis,which,type
- 『Python』os库练习题及答案
- Calling C# Methods From C++
- java 线程六-解决线程安全隐患问题-加锁
- log4j-1简单介绍与配置--eclipse
- 算法学习--栈的小应用
- linux基础(15)--locate、find命令的使用--RHEL6.5
- Mysql 启动 windows
- STL vector用法介绍
- java 线程七-Lock锁
- Fragment之我的解决方案:Fragmentation
- 单元测试 mock EF 中DbContext 和DbSet Include
- 手把手教你SOAP访问webservice并DOM解析返回的XML数据
- ElasticSearch部署
- Flume与SparkStreaming集成