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
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 經常使用選項:文檔
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 建立時間:-
[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表示或者 ,三個條件只須要知足一個便可。用法少。
#經常使用選項: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文件後綴名不嚴格區分,給文件添加後綴的目的是爲了方便區分。