find命令平常用法和文件名后缀

9月18日任务

 

2.23/2.24/2.25 find命令node

2.26 文件名后缀linux

 

2.23 、find命令 :文件搜索命令数据库

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

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

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

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

 

经常使用快捷键介绍:ssh

  • ctrl +d       关闭窗口 至关于logou
  • ctrl +l       清屏 至关于命令clear
  • ctrl +u       快捷删除已经输入光标前的内容
  • ctrl +c       结束当前操做
  • ctrl +a       光标移动至首位
  • ctel +e       光标移至末尾

find命令用法介绍spa

[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    查看文件信息get

[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文件后缀名不严格区分,给文件添加后缀的目的是为了方便区分。

相关文章
相关标签/搜索