whereis
locate:
[root@localhost ~]# yum install -y mlocate
[root@localhost ~]# locate ls //每天凌晨4点自动生成
locate: can not stat () `/var/lib/mlocate/mlocate.db‘: No such file or directory
[root@localhost ~]# locate lsx //会把带有这个字符的都找出来
/home/lsx
/home/lsx/.bash_logout
/home/lsx/.bash_profile
/home/lsx/.bashrc
/root/lsx
/root/lsx/111
/var/spool/mail/lsx
ctrl+c是强制中断程序的执行
ctrl+z的是将任务中止(暂停的意思)
ctrl-d表示退出当前shell
[root@localhost ~]# find /tmp/ -name yum.log //只知道名字和路径搜索
/tmp/yum.log
[root@localhost ~]# find /tmp/ -name y* //名字记不清了
/tmp/yum.log
type类型有:f、d、l、s、c(字符串设备)、b
[root@localhost ~]# find /tmp/ -name y* -type d //搜索目录(或者文件f)名字不太清的情况
[root@localhost ~]# find /root/ -type l //搜索软链接
/root/lsx/111
/root/1_soft.txt
atime 文件访问时间、
ctime 改变文件属性、
mtime 改变文件内容。(改变文件内容ctime一定会变,因为ctime记录文件时间,大小,大小变了)
[root@localhost ~]# stat 1_hard.txt
File: ‘1_hard.txt‘
Size: 973 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051dInode: 33895969 Links: 2
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:admin_home_t:s0
Access: 2017-10-15 22:41:18.762003887 +0800 //最近访问
Modify: 2017-10-15 22:41:18.769003887 +0800 //最近更改
Change: 2017-10-21 04:41:41.990537620 +0800 //最近改动
Birth: -
改变文件内容ctime一定会变,因为ctime记录文件时间,大小,大小变了
[root@localhost ~]# echo "sda">>lsx.txt
[root@localhost ~]# stat lsx.txt
File: ‘lsx.txt‘
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051dInode: 34383610 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-10-21 06:53:45.684631141 +0800
Modify: 2017-10-21 06:54:04.602631364 +0800
Change: 2017-10-21 06:54:04.602631364 +0800
Birth: -
-1 一天以内
+1 一天以前
[root@localhost ~]# find /root -type f -mtime -1 //在/root目录下寻找一天以内内容更改的文件
/root/.bash_history
/root/.lesshst
/root/lsx.txt
[root@localhost ~]# find /root -type f -o -atime -1 -o -name lsx.* //-o或者
/root
/root/.bash_logout
/root/.bash_profile
[root@localhost ~]# ll -i
total 12
33895969 -rwxrwxrwx. 2 root root 973 Oct 15 22:41 1_hard.txt
34383604 lrwxrwxrwx. 1 root root 15 Oct 21 04:41 1_soft.txt -> anaconda-ks.cfg
33895969 -rwxrwxrwx. 2 root root 973 Oct 15 22:41 anaconda-ks.cfg
根据inode查找文件
[root@localhost ~]# find / -type f -inum 33895969
/root/anaconda-ks.cfg
/root/1_hard.txt
一小时以内的改变文件内容的mmin、amin、cmin
[root@localhost ~]# find /root -type f -mmin -60
/root/lsx.txt
[root@localhost ~]# find /root -type f -cmin -60 -exec ls -l {} \;
-rwxrwxrwx. 2 root root 973 Oct 15 22:41 /root/anaconda-ks.cfg
-rwxrwxrwx. 2 root root 973 Oct 15 22:41 /root/1_hard.txt
-rwxrwxrwx. 1 root root 6 Oct 21 06:55 /root/lsx.txt
[root@localhost ~]# find /root/ -type f -mmin -60 -exec mv {} {}.bak \;
[root@localhost ~]# find /root -type f -cmin -60
/root/lsx.txt.bak
文件大小
[root@localhost ~]# find /root/ -size +2k
/root/
/root/.bash_history
[root@localhost ~]# find / -type f -size +10M //文件大小大于10M的
/boot/initramfs-0-rescue-2ba7435fb8a348109570f5a113e9dc5d.img
/proc/kcore
Linux后缀不严谨、可以自定义文件名。不能代表这个文件的类型。
习惯于相同类型的文件,定义相同类型的后缀名。便于区分
本文出自 “帕多克的痴迷” 博客,请务必保留此出处http://lsxme.blog.51cto.com/12400127/1975891
原文地址:http://lsxme.blog.51cto.com/12400127/1975891