linux查找补全文件名,find命令日常用法和文件名后缀

9月18日任务

2.23/2.24/2.25 find命令

2.26 文件名后缀

2.23 、find命令 :文件搜索命令

#跟find相关的几个文件搜索命令

which #根据PATH查询命令位置。

whereis #搜索命令及文件位置,搜索不全面,不常用。

locate # yum install -y mlocate 这个命令需要用yum源安装,安装完需要同步数据库,运行updatedb 同步。

常用快捷键介绍:

ctrl +d       关闭窗口 相当于logou

ctrl +l       清屏 相当于命令clear

ctrl +u       快捷删除已经输入光标前的内容

ctrl +c       结束当前操作

ctrl +a       光标移动至首位

ctel +e       光标移至末尾

find命令用法介绍

[root@zgxlinux-01 ~]# find /etc/ -name "ssh_config" #按文件路径和文件名搜索

/etc/ssh/ssh_config

[root@zgxlinux-01 ~]# find /etc/ -name "sshd*" #模糊搜索,以sshd起始的命名文件都搜索出来

/etc/pam.d/sshd

/etc/systemd/system/multi-user.target.wants/sshd.service

/etc/sysconfig/sshd

/etc/ssh/sshd_config

[root@zgxlinux-01 ~]# find /etc/ -type d -name "sshd*" #搜索etc下的目录,命名以sshd起始的目录,搜索出来没有。

[root@zgxlinux-01 ~]# find /etc/ -type f -name "sshd*" #搜索etc下的文件,命名以sshd起始的目录。

/etc/pam.d/sshd

/etc/sysconfig/sshd

/etc/ssh/sshd_config

find -type 常用选项:

find -type d -name  #目录

find -type f -name   #文件

find -type l -name    #软链接

find -type s -name    #soukt文件

find -type b -name  #块设备文件

find -type c -name   #字符串设备

2.24 、find命令(中)

命令 :stat    查看文件信息

[root@zgxlinux-01 ~]# stat anaconda-ks.cfg

文件:"anaconda-ks.cfg"

大小:2557 块:8 IO 块:4096 普通文件

设备:803h/2051d Inode:33582978 硬链接:1

权限:(0600/-rw-------) Uid:( 0/ root) Gid:( 0/ root)

环境:system_u:object_r:admin_home_t:s0

最近访问:2018-09-04 13:07:34.796488030 +0800

最近更改:2018-09-04 13:07:34.796488030 +0800

最近改动:2018-09-04 13:07:34.796488030 +0800

创建时间:-

find -mtime   最近更改(内容)工作中常用

find -atime    最近访问

find -ctime    最近改动(inode、权限、文件名)

[root@zgxlinux-01 ~]# find /etc/ -type f -mtime -1 #搜索/etc/下载一天内修改过的文档。

/etc/resolv.conf

/etc/tuned/active_profile

/etc/tuned/profile_mode

[root@zgxlinux-01 ~]# find /etc/ -type f -mtime -1 -name "*.conf" #搜索/etc/下是文件并且修改时间在1天以内并且以.conf结尾的文件

/etc/resolv.conf

[root@zgxlinux-01 ~]# find /etc/ -type f -o -mtime -1 -o -name "*.conf" #-o表示或者 ,三个条件只需要满足一个即可。用法少。

2.25 、  find命令(下)

#常用选项:find -type文件类型   、find -mtime 多少天内 、  find -mmin 多少分钟 、 find  -exec匹配使用

#如何查找硬链接文件   find -inum 按照inode号查找硬链接文件。

[root@zgxlinux-01 ~]# ln 1.txt /tmp/1.txt.bak

[root@zgxlinux-01 ~]# ls -i 1.txt

33583024 1.txt

[root@zgxlinux-01 ~]# find / -inum 33583024

/root/1.txt

/tmp/1.txt.bak

[root@zgxlinux-01 ~]# find /root/ -type f -mmin -2000 #查找root下文件修改时间在2000分钟以内的文件

/root/.bash_history

/root/1.txt

[root@zgxlinux-01 ~]# find /root/ -type f -mmin -2000 -exec ls -l {} \; #查找文件的同时列出详细信息

-rw-------. 1 root root 23886 9月 17 17:48 /root/.bash_history

-rw-r--r--. 2 root root 0 9月 17 15:00 /root/1.txt

[root@zgxlinux-01 ~]# find /root/ -type f -mmin -2000 -exec mv {} {}.bak \; #查找文件的同时修改文件名

[root@zgxlinux-01 ~]# find /root/ -type f -mmin -2000

/root/.bash_history.bak

/root/1.txt.bak

2.26 、文件后缀名

#Linux文件后缀名不严格区分,给文件添加后缀的目的是为了方便区分。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值