10. find

来源:互联网 发布:淘宝千人千面原理 编辑:程序博客网 时间:2024/06/16 20:52
2.23/2.24/2.25 find命令
whatis (1) - display manual page descriptions
whereis (1) - locate the binary, source, and manual page files for a command
which (1) - shows the full path of (shell) commands.

yum -y install mlocate
updatedb
快捷键:
^d:退出或向后逐字符删除
^u:删除光标前所有字符
^k:删除光标后所有字符

find /etc/ -type f -name "sshd*"

stat - display file or file system status

touch - change file timestamps
Update the access and modification times of each FILE to the current time.
mtime(modify time):文件内容更改时间
ctime(change time):文件状态更改时间,例如权限及属性
atime(access time):访问时间

find / -mtime 0 //查找24H之内被改动过的文件
-mtime n
File's data was last modified n*24 hours ago.

find /etc/ -type f -mtime -1

find /home -user vbird
find / -nouser
find / -nogroup

find / -perm +7000 // 查找含有suid或sgid或sbit属性的文件
find /bin /sbin -perm +6000
find / -perm +7000 -exec ls -l {} \;

find / -size +1000k
find / -size +1000M

find /etc -name '*httpd*'
find / -type f -mtime 1 | wc -l
find /etc -type f -ctime -1 -name "*.conf"

-inum n
File has inode number n.It is normally easier to use the -samefiletest instead.
find . -inum 16798157
-samefile name
File refers to the same inode as name.
When -L is in effect, this can include symbolic links.
find . -samefile a
-L Follow symbolic links.
-mmin n
File's data was last modified n minutes ago.
find . -mmin -60
find . -mmin -12 -exec ls -l {} \;
find . -type f -mmin 150 -exec cp {} {}.bak \;
find . -inum 16798157 -exec cp {} {}.bak \;

find . -size -10k -type f -exec ls -lh {} \;
find . -size +10k -type f -exec ls -lh {} \;
# find /root/ -size +10K -type f -exec ls -lh {} \;
find: 无效的 -size 类型“K”
# find /root/ -size +10m -type f -exec ls -lh {} \;
find: 无效的 -size 类型“m”
# find /root/ -size -10M -type f -exec ls -lh {} \;
……
find . -maxdepth 1 -type f -size -1k -exec rm {} \;
原创粉丝点击