find命令 文件名后缀

快捷键:

crtl l 清屏

crtl d 退出一个终端

ctrl c 不执行命令

crtl u 把前面的东西全部删掉

crtl e 把光标一下子移到后面

crtl a 把光标移到最开始

[root@lizhipeng01 ~]# find /etc/ -name "sshd_config"     知道名字,不知道路径
/etc/ssh/sshd_config
[root@lizhipeng01 ~]# find /etc/ -name "sshd*"                名字和路径都不清楚,模糊搜索
/etc/systemd/system/multi-user.target.wants/sshd.service
/etc/sysconfig/sshd
/etc/ssh/sshd_config
/etc/pam.d/sshd
[root@lizhipeng01 ~]# find /etc/ -type d -name "sshd*"      查带sshd的目录
[root@lizhipeng01 ~]# find /etc/ -type f -name "sshd*"  查带sshd的文件
/etc/sysconfig/sshd
/etc/ssh/sshd_config
/etc/pam.d/sshd

[root@lizhipeng01 ~]# ls
111 1.txt 2.txt a.txt dir2 dir4 test4 testb.txt yum.log
123 234 anaconda-ks.cfg bb dir3 split_dir test5 testc.txt 学习计划安排.txt
[root@lizhipeng01 ~]# stat 2.txt
文件:"2.txt"
大小:958 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:101507522 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2017-12-18 05:04:34.943913445 +0800 atime
最近更改:2017-12-18 05:29:22.134827713 +0800 mtime
最近改动:2017-12-18 05:52:55.942746211 +0800 ctime
创建时间:-

更改了文件内容一定会更改ctime ,即更改mtime同时会更改ctime,反之不成立

[root@lizhipeng01 ~]# cat 2.txt

[root@lizhipeng01 ~]# stat 2.txt
文件:"2.txt"
大小:958 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:101507522 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2017-12-21 05:53:54.777360509 +0800       atime发生改变
最近更改:2017-12-18 05:29:22.134827713 +0800
最近改动:2017-12-18 05:52:55.942746211 +0800
创建时间:-

[root@lizhipeng01 ~]# echo "111" >> 2.txt                     mtime发生改变,同时ctime改变
[root@lizhipeng01 ~]# stat 2.txt
文件:"2.txt"
大小:962 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:101507522 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2017-12-21 05:53:54.777360509 +0800
最近更改:2017-12-21 05:55:37.366365900 +0800
最近改动:2017-12-21 05:55:37.366365900 +0800
创建时间:-

[root@lizhipeng01 ~]# chmod 777 2.txt               ctime发生改变,但是mtime并没有发生改变
[root@lizhipeng01 ~]# stat 2.txt
文件:"2.txt"
大小:962 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:101507522 硬链接:1
权限:(0777/-rwxrwxrwx) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2017-12-21 05:53:54.777360509 +0800
最近更改:2017-12-21 05:55:37.366365900 +0800
最近改动:2017-12-21 05:56:46.578369538 +0800
创建时间:-

[root@lizhipeng01 ~]# find / -type f -mtime -1  查找一天以内被修改过内容的文件    +1一天以外

[root@lizhipeng01 ~]# find /etc/ -type f -ctime -1 -name "*.conf"
/etc/resolv.conf

[root@lizhipeng01 ~]# find /etc/ -type f -mtime -1 -name "*.conf"
/etc/resolv.conf

[root@lizhipeng01 ~]# find /etc/ -type f -o -mtime -1 -o -name "*.conf"    -o或者的意思

[root@lizhipeng01 ~]# ln 1.txt 1_hard.txt
[root@lizhipeng01 ~]# ls -l
总用量 36
drwxr-xr-x. 2 root root 23 12月 21 04:41 111
drwxr-xr-x. 2 root root 40 12月 21 04:41 123
-rw-r--r--. 2 root root 16 12月 18 06:58 1_hard.txt
-rw-r--r--. 2 root root 16 12月 18 06:58 1.txt

[root@lizhipeng01 ~]# ln 1_hard.txt /tmp/1.txt.bak

[root@lizhipeng01 ~]# ls -l 1_hard.txt
-rw-r--r--. 2 root root 16 12月 18 06:58 1_hard.txt

[root@lizhipeng01 ~]# ls -i 1_hard.txt
67947662 1_hard.txt

[root@lizhipeng01 ~]# find / -inum 67947662  查找文件的硬链接
/root/1_hard.txt
/tmp/1.txt.bak

[root@lizhipeng01 ~]# find /root/ -type f -mmin -60  一小时以内修改的文件

/root/2.txt

[root@lizhipeng01 ~]# find /root/ -type f -mmin -120 -exec ls -l {} ; 查找并显示出来
-rwxrwxrwx. 1 root root 962 12月 21 05:55 /root/2.txt

[root@lizhipeng01 ~]# find /root/ -type f -mmin -200 -exec mv {} {}.bak ; 查找并修改名字
[root@lizhipeng01 ~]# find /root/ -type f -mmin -200
/root/2.txt.bak

[root@lizhipeng01 ~]# find /root/ -type f -size +10k -exec ls -lh {} ;  查找大于10K的文件
-rw-------. 1 root root 16K 12月 20 07:57 /root/.bash_history

[root@lizhipeng01 ~]# LANG=en
[root@lizhipeng01 ~]# stat 2.txtbak
stat: cannot stat '2.txtbak': No such file or directory
[root@lizhipeng01 ~]# stat 2.txt.bak
File: '2.txt.bak'
Size: 962 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 101507522 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2017-12-21 05:53:54.777360509 +0800
Modify: 2017-12-21 05:55:37.366365900 +0800
Change: 2017-12-21 06:20:29.161444306 +0800
Birth: -

[root@lizhipeng01 ~]# echo $LANG                          另一个终端
zh_CN.UTF-8
[root@lizhipeng01 ~]# stat 2.txt.bak
文件:"2.txt.bak"
大小:962 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:101507522 硬链接:1
权限:(0777/-rwxrwxrwx) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2017-12-21 05:53:54.777360509 +0800
最近更改:2017-12-21 05:55:37.366365900 +0800
最近改动:2017-12-21 06:20:29.161444306 +0800
创建时间:-

原文地址:https://www.cnblogs.com/sisul/p/8076187.html