Linux操作系统的文件查找工具locate和find命令常用参数介绍

                                             作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.非实时查找(数据库查找)locate工具 

locate命令的工作原理剖析:
  用locate命令在搜索文件列表的时候,它并不是去硬盘中实时搜索文件,而是事先把磁盘上的所有文件预建文件索引数据库(即"/var/lib/mlocate.db"),查询时依赖于事先构建的索引(索引的构建是在系统较为空闲时自动进行,即周期性任务),这就是为什么它搜索文件非常快的原因。
  但这并不是说安装操作系统或者刚刚安装完locate软件,就会立即有"/var/lib/mlocate.db"数据库的,而是需要等待一段时间后它才会自动生成,而这个等待时间是不确定的,因此我们可以使用update命令来手动生成该索引数据库文件。
  索引构建过程需要遍历整个根文件系统,极消耗资源,因此locate命令适合搜索比较稳定的文件,比如系统的启动脚本或系统配置文件之类的,因为他们不仅经常变化,基本上都可以搜索到,但是对于一些变化频率比较高的文件搜索起来locate就有点力不从心,需要咱们不断地手动更新数据库才能获取到最新的文件索引信息。 locate命令的工作特点:
  (1)查找速度快
  (2)模糊查找
  (3)非实时查找
  (4)搜索的文件是全路径,不仅仅是文件名
  (5)可能之搜索用户具备读取和执行权限的目录 locate语法格式:
  Usage: locate [OPTION]... [PATTERN]...
  常用选项:
    -i:
      不区分大小写。
    -n N:
      只例举前N个匹配项目。
    -r:
      使用正则biao a  

1>.安装locate数据库(最小化操作系统是没有安装locate命令的哟~)

[root@node101.yinzhengjie.org.cn ~]# yum -y install mlocate
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package mlocate.x86_64 :0.26-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================
Installing:
mlocate x86_64 0.26-.el7 base k Transaction Summary
=================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
mlocate-0.26-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mlocate-0.26-.el7.x86_64 /
Verifying : mlocate-0.26-.el7.x86_64 / Installed:
mlocate.x86_64 :0.26-.el7 Complete!
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# yum -y install mlocate

2>.更新locate的数据库文件

[root@node101.yinzhengjie.org.cn ~]# locate hosts              #我们在安装locate命令时并不会立即生成数据索引文件。
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# updatedb                 #因此我们可以手动locate命令的数据库文件,如果文件已经存在则更新该数据库内容。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /var/lib/mlocate/mlocate.db    #数据库文件竟然自动创建出来啦
-rw-r----- root slocate Dec : /var/lib/mlocate/mlocate.db
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# touch f1.log              #我们此处创建一个文件
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll                    #该文件已经创建出来来
total
-rw-r--r-- root root Dec : f1.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# locate f1.log             #我们发现locate命令竟然找不到f1.log文件,这是由于locate的数据库文件还没有来得及更新
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# updatedb                 #于是于是我们手动更新数据库信息,将之前修改的内容都同步到locate数据库中
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# locate f1.log              #
/root/f1.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

3>.省略选项搜索关键词案例

[root@node101.yinzhengjie.org.cn ~]# locate hosts
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/active/modules//denyhosts
/etc/selinux/targeted/active/modules//denyhosts/cil
/etc/selinux/targeted/active/modules//denyhosts/hll
/etc/selinux/targeted/active/modules//denyhosts/lang_ext
/usr/lib64/security/pam_rhosts.so
/usr/share/ghostscript
/usr/share/doc/httpd-2.4./httpd-vhosts.conf
/usr/share/doc/pam-1.1./html/sag-pam_rhosts.html
/usr/share/doc/pam-1.1./txts/README.pam_rhosts
/usr/share/ghostscript/conf.d
/usr/share/man/man5/hosts.allow..gz
/usr/share/man/man5/hosts.deny..gz
/usr/share/man/man5/hosts_access..gz
/usr/share/man/man5/hosts_options..gz
/usr/share/man/man8/pam_rhosts..gz
/usr/share/vim/vim74/ftplugin/denyhosts.vim
/usr/share/vim/vim74/ftplugin/hostsaccess.vim
/usr/share/vim/vim74/syntax/denyhosts.vim
/usr/share/vim/vim74/syntax/hostsaccess.vim
/usr/share/zsh/site-functions/_sd_hosts_or_user_at_host
/var/cache/yum/x86_64//timedhosts
/var/cache/yum/x86_64//timedhosts.txt
/var/www/html/phpMyAdmin/examples/config.manyhosts.inc.php
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# locate hosts            #查找文件名包含hosts的文件名或者路径。

4>."-i"选项案例

[root@node101.yinzhengjie.org.cn ~]# locate HOSTS          #我们搜索大写的关键词是搜不到有关HOSTS文件名称或路径的。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# locate -i HOSTS        #我们使用"-i"选项可以忽略文件大小写,瞬间就可以匹配到包含hosts的文件名称或路径啦。
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/active/modules//denyhosts
/etc/selinux/targeted/active/modules//denyhosts/cil
/etc/selinux/targeted/active/modules//denyhosts/hll
/etc/selinux/targeted/active/modules//denyhosts/lang_ext
/usr/lib64/security/pam_rhosts.so
/usr/share/ghostscript
/usr/share/doc/httpd-2.4./httpd-vhosts.conf
/usr/share/doc/pam-1.1./html/sag-pam_rhosts.html
/usr/share/doc/pam-1.1./txts/README.pam_rhosts
/usr/share/ghostscript/conf.d
/usr/share/man/man5/hosts.allow..gz
/usr/share/man/man5/hosts.deny..gz
/usr/share/man/man5/hosts_access..gz
/usr/share/man/man5/hosts_options..gz
/usr/share/man/man8/pam_rhosts..gz
/usr/share/vim/vim74/ftplugin/denyhosts.vim
/usr/share/vim/vim74/ftplugin/hostsaccess.vim
/usr/share/vim/vim74/syntax/denyhosts.vim
/usr/share/vim/vim74/syntax/hostsaccess.vim
/usr/share/zsh/site-functions/_sd_hosts_or_user_at_host
/var/cache/yum/x86_64//timedhosts
/var/cache/yum/x86_64//timedhosts.txt
/var/www/html/phpMyAdmin/examples/config.manyhosts.inc.php
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# locate -i HOSTS          #我们使用"-i"选项可以忽略文件大小写,瞬间就可以匹配到包含hosts的文件名称或路径啦。

5>."-n"选项案例

[root@node101.yinzhengjie.org.cn ~]# locate hosts
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/active/modules//denyhosts
/etc/selinux/targeted/active/modules//denyhosts/cil
/etc/selinux/targeted/active/modules//denyhosts/hll
/etc/selinux/targeted/active/modules//denyhosts/lang_ext
/usr/lib64/security/pam_rhosts.so
/usr/share/ghostscript
/usr/share/doc/httpd-2.4./httpd-vhosts.conf
/usr/share/doc/pam-1.1./html/sag-pam_rhosts.html
/usr/share/doc/pam-1.1./txts/README.pam_rhosts
/usr/share/ghostscript/conf.d
/usr/share/man/man5/hosts.allow..gz
/usr/share/man/man5/hosts.deny..gz
/usr/share/man/man5/hosts_access..gz
/usr/share/man/man5/hosts_options..gz
/usr/share/man/man8/pam_rhosts..gz
/usr/share/vim/vim74/ftplugin/denyhosts.vim
/usr/share/vim/vim74/ftplugin/hostsaccess.vim
/usr/share/vim/vim74/syntax/denyhosts.vim
/usr/share/vim/vim74/syntax/hostsaccess.vim
/usr/share/zsh/site-functions/_sd_hosts_or_user_at_host
/var/cache/yum/x86_64//timedhosts
/var/cache/yum/x86_64//timedhosts.txt
/var/www/html/phpMyAdmin/examples/config.manyhosts.inc.php
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# locate -n hosts          #之列出前5个匹配到的文件名称或路径名称
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/active/modules//denyhosts
/etc/selinux/targeted/active/modules//denyhosts/cil
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# locate -n 5 hosts          #之列出前5个匹配到的文件名称或路径名称

6>."-r"选项案例

[root@node101.yinzhengjie.org.cn ~]# locate -r "\.conf$"
/etc/GeoIP.conf
/etc/asound.conf
/etc/chrony.conf
/etc/dracut.conf
/etc/e2fsck.conf
/etc/host.conf
/etc/kdump.conf
/etc/krb5.conf
/etc/ld.so.conf
/etc/libaudit.conf
/etc/libuser.conf
/etc/locale.conf
/etc/logrotate.conf
/etc/man_db.conf
/etc/mke2fs.conf
/etc/nsswitch.conf
/etc/resolv.conf
/etc/rsyncd.conf
/etc/rsyslog.conf
/etc/sestatus.conf
/etc/sudo-ldap.conf
/etc/sudo.conf
/etc/sysctl.conf
/etc/updatedb.conf
/etc/vconsole.conf
/etc/yum.conf
/etc/NetworkManager/NetworkManager.conf
/etc/X11/xorg.conf.d/-keyboard.conf
/etc/audisp/audispd.conf
/etc/audisp/plugins.d/af_unix.conf
/etc/audisp/plugins.d/syslog.conf
/etc/audit/auditd.conf
/etc/dbus-/session.conf
/etc/dbus-/system.conf
/etc/dbus-/system.d/FirewallD.conf
/etc/dbus-/system.d/com.redhat.tuned.conf
/etc/dbus-/system.d/nm-dispatcher.conf
/etc/dbus-/system.d/nm-ifcfg-rh.conf
/etc/dbus-/system.d/org.freedesktop.NetworkManager.conf
/etc/dbus-/system.d/org.freedesktop.PolicyKit1.conf
/etc/dbus-/system.d/org.freedesktop.hostname1.conf
/etc/dbus-/system.d/org.freedesktop.import1.conf
/etc/dbus-/system.d/org.freedesktop.locale1.conf
/etc/dbus-/system.d/org.freedesktop.login1.conf
/etc/dbus-/system.d/org.freedesktop.machine1.conf
/etc/dbus-/system.d/org.freedesktop.systemd1.conf
/etc/dbus-/system.d/org.freedesktop.timedate1.conf
/etc/dbus-/system.d/teamd.conf
/etc/dbus-/system.d/wpa_supplicant.conf
/etc/depmod.d/dist.conf
/etc/firewalld/firewalld.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/-base.conf
/etc/httpd/conf.modules.d/-dav.conf
/etc/httpd/conf.modules.d/-lua.conf
/etc/httpd/conf.modules.d/-mpm.conf
/etc/httpd/conf.modules.d/-proxy.conf
/etc/httpd/conf.modules.d/-systemd.conf
/etc/httpd/conf.modules.d/-cgi.conf
/etc/httpd/conf.modules.d/-php.conf
/etc/ld.so.conf.d/kernel-3.10.-.el7.x86_64.conf
/etc/ld.so.conf.d/mariadb-x86_64.conf
/etc/lvm/lvm.conf
/etc/lvm/lvmlocal.conf
/etc/modprobe.d/dccp-blacklist.conf
/etc/modprobe.d/firewalld-sysctls.conf
/etc/modprobe.d/tuned.conf
/etc/openldap/ldap.conf
/etc/pki/ca-trust/ca-legacy.conf
/etc/plymouth/plymouthd.conf
/etc/prelink.conf.d/fipscheck.conf
/etc/prelink.conf.d/grub2.conf
/etc/prelink.conf.d/nss-softokn-prelink.conf
/etc/rsyslog.d/listen.conf
/etc/sasl2/smtpd.conf
/etc/security/access.conf
/etc/security/chroot.conf
/etc/security/group.conf
/etc/security/limits.conf
/etc/security/namespace.conf
/etc/security/pam_env.conf
/etc/security/pwquality.conf
/etc/security/sepermit.conf
/etc/security/time.conf
/etc/security/limits.d/-nproc.conf
/etc/selinux/semanage.conf
/etc/selinux/targeted/setrans.conf
/etc/sysctl.d/-sysctl.conf
/etc/systemd/bootchart.conf
/etc/systemd/coredump.conf
/etc/systemd/journald.conf
/etc/systemd/logind.conf
/etc/systemd/system.conf
/etc/systemd/user.conf
/etc/tuned/tuned-main.conf
/etc/udev/udev.conf
/etc/wpa_supplicant/wpa_supplicant.conf
/etc/yum/version-groups.conf
/etc/yum/pluginconf.d/fastestmirror.conf
/etc/yum/pluginconf.d/langpacks.conf
/etc/yum/protected.d/systemd.conf
/home/yinzhengjie/.pyenv/.pip/pip.conf
/home/yinzhengjie/.pyenv/cache/Python-3.6./Doc/docutils.conf
/home/yinzhengjie/.pyenv/cache/Python-3.6./Doc/tools/pydoctheme/theme.conf
/usr/lib/NetworkManager/conf.d/-slaves-order.conf
/usr/lib/dracut/dracut.conf.d/-dist.conf
/usr/lib/dracut/dracut.conf.d/-microcode.conf
/usr/lib/dracut/dracut.conf.d/-rescue.conf
/usr/lib/dracut/dracut.conf.d/-nss-softokn.conf
/usr/lib/dracut/dracut.conf.d/-phys-port-name.conf
/usr/lib/dracut/modules.d/40network/dhclient.conf
/usr/lib/dracut/modules.d/98syslog/rsyslog.conf
/usr/lib/dracut/modules.d/98systemd/dracut-tmpfiles.conf
/usr/lib/modprobe.d/dist-alsa.conf
/usr/lib/modprobe.d/dist-blacklist.conf
/usr/lib/sysctl.d/-system.conf
/usr/lib/sysctl.d/-default-yama-scope.conf
/usr/lib/sysctl.d/-default.conf
/usr/lib/tmpfiles.d/cryptsetup.conf
/usr/lib/tmpfiles.d/etc.conf
/usr/lib/tmpfiles.d/httpd.conf
/usr/lib/tmpfiles.d/initscripts.conf
/usr/lib/tmpfiles.d/legacy.conf
/usr/lib/tmpfiles.d/libselinux.conf
/usr/lib/tmpfiles.d/lvm2.conf
/usr/lib/tmpfiles.d/mariadb.conf
/usr/lib/tmpfiles.d/pam.conf
/usr/lib/tmpfiles.d/python.conf
/usr/lib/tmpfiles.d/rpm.conf
/usr/lib/tmpfiles.d/sap.conf
/usr/lib/tmpfiles.d/selinux-policy.conf
/usr/lib/tmpfiles.d/sudo.conf
/usr/lib/tmpfiles.d/systemd-nologin.conf
/usr/lib/tmpfiles.d/systemd.conf
/usr/lib/tmpfiles.d/tmp.conf
/usr/lib/tmpfiles.d/tuned.conf
/usr/lib/tmpfiles.d/var.conf
/usr/lib/tmpfiles.d/x11.conf
/usr/lib/tuned/balanced/tuned.conf
/usr/lib/tuned/desktop/tuned.conf
/usr/lib/tuned/latency-performance/tuned.conf
/usr/lib/tuned/network-latency/tuned.conf
/usr/lib/tuned/network-throughput/tuned.conf
/usr/lib/tuned/powersave/tuned.conf
/usr/lib/tuned/recommend.d/-tuned.conf
/usr/lib/tuned/throughput-performance/tuned.conf
/usr/lib/tuned/virtual-guest/tuned.conf
/usr/lib/tuned/virtual-host/tuned.conf
/usr/share/alsa/alsa.conf
/usr/share/alsa/cards/AACI.conf
/usr/share/alsa/cards/ATIIXP-MODEM.conf
/usr/share/alsa/cards/ATIIXP-SPDMA.conf
/usr/share/alsa/cards/ATIIXP.conf
/usr/share/alsa/cards/AU8810.conf
/usr/share/alsa/cards/AU8820.conf
/usr/share/alsa/cards/AU8830.conf
/usr/share/alsa/cards/Audigy.conf
/usr/share/alsa/cards/Audigy2.conf
/usr/share/alsa/cards/Aureon51.conf
/usr/share/alsa/cards/Aureon71.conf
/usr/share/alsa/cards/CA0106.conf
/usr/share/alsa/cards/CMI8338-SWIEC.conf
/usr/share/alsa/cards/CMI8338.conf
/usr/share/alsa/cards/CMI8738-MC6.conf
/usr/share/alsa/cards/CMI8738-MC8.conf
/usr/share/alsa/cards/CMI8788.conf
/usr/share/alsa/cards/CS46xx.conf
/usr/share/alsa/cards/EMU10K1.conf
/usr/share/alsa/cards/EMU10K1X.conf
/usr/share/alsa/cards/ENS1370.conf
/usr/share/alsa/cards/ENS1371.conf
/usr/share/alsa/cards/ES1968.conf
/usr/share/alsa/cards/Echo_Echo3G.conf
/usr/share/alsa/cards/FM801.conf
/usr/share/alsa/cards/FWSpeakers.conf
/usr/share/alsa/cards/FireWave.conf
/usr/share/alsa/cards/GUS.conf
/usr/share/alsa/cards/HDA-Intel.conf
/usr/share/alsa/cards/HdmiLpeAudio.conf
/usr/share/alsa/cards/ICE1712.conf
/usr/share/alsa/cards/ICE1724.conf
/usr/share/alsa/cards/ICH-MODEM.conf
/usr/share/alsa/cards/ICH.conf
/usr/share/alsa/cards/ICH4.conf
/usr/share/alsa/cards/Loopback.conf
/usr/share/alsa/cards/Maestro3.conf
/usr/share/alsa/cards/NFORCE.conf
/usr/share/alsa/cards/PC-Speaker.conf
/usr/share/alsa/cards/PMac.conf
/usr/share/alsa/cards/PMacToonie.conf
/usr/share/alsa/cards/PS3.conf
/usr/share/alsa/cards/RME9636.conf
/usr/share/alsa/cards/RME9652.conf
/usr/share/alsa/cards/SB-XFi.conf
/usr/share/alsa/cards/SI7018.conf
/usr/share/alsa/cards/TRID4DWAVENX.conf
/usr/share/alsa/cards/USB-Audio.conf
/usr/share/alsa/cards/VIA686A.conf
/usr/share/alsa/cards/VIA8233.conf
/usr/share/alsa/cards/VIA8233A.conf
/usr/share/alsa/cards/VIA8237.conf
/usr/share/alsa/cards/VX222.conf
/usr/share/alsa/cards/VXPocket.conf
/usr/share/alsa/cards/VXPocket440.conf
/usr/share/alsa/cards/YMF744.conf
/usr/share/alsa/cards/aliases.conf
/usr/share/alsa/cards/pistachio-card.conf
/usr/share/alsa/cards/vc4-hdmi.conf
/usr/share/alsa/firmware/usx2yloader/us122.conf
/usr/share/alsa/firmware/usx2yloader/us224.conf
/usr/share/alsa/firmware/usx2yloader/us428.conf
/usr/share/alsa/pcm/center_lfe.conf
/usr/share/alsa/pcm/default.conf
/usr/share/alsa/pcm/dmix.conf
/usr/share/alsa/pcm/dpl.conf
/usr/share/alsa/pcm/dsnoop.conf
/usr/share/alsa/pcm/front.conf
/usr/share/alsa/pcm/hdmi.conf
/usr/share/alsa/pcm/iec958.conf
/usr/share/alsa/pcm/modem.conf
/usr/share/alsa/pcm/rear.conf
/usr/share/alsa/pcm/side.conf
/usr/share/alsa/pcm/surround21.conf
/usr/share/alsa/pcm/surround40.conf
/usr/share/alsa/pcm/surround41.conf
/usr/share/alsa/pcm/surround50.conf
/usr/share/alsa/pcm/surround51.conf
/usr/share/alsa/pcm/surround71.conf
/usr/share/alsa/topology/broadwell/broadwell.conf
/usr/share/alsa/topology/bxtrt298/bxt_i2s.conf
/usr/share/alsa/topology/sklrt286/skl_i2s.conf
/usr/share/dbus-/session.conf
/usr/share/dbus-/system.conf
/usr/share/doc/NetworkManager/examples/server.conf
/usr/share/doc/alsa-lib/modprobe-dist-oss.conf
/usr/share/doc/dbus-1.10./examples/example-session-disable-stats.conf
/usr/share/doc/dbus-1.10./examples/example-system-enable-stats.conf
/usr/share/doc/glibc-common-2.17/gai.conf
/usr/share/doc/gnupg2-2.0./examples/gpgconf.conf
/usr/share/doc/httpd-2.4./httpd-dav.conf
/usr/share/doc/httpd-2.4./httpd-default.conf
/usr/share/doc/httpd-2.4./httpd-info.conf
/usr/share/doc/httpd-2.4./httpd-languages.conf
/usr/share/doc/httpd-2.4./httpd-manual.conf
/usr/share/doc/httpd-2.4./httpd-mpm.conf
/usr/share/doc/httpd-2.4./httpd-multilang-errordoc.conf
/usr/share/doc/httpd-2.4./httpd-vhosts.conf
/usr/share/doc/httpd-2.4./proxy-html.conf
/usr/share/doc/krb5-libs-1.15./examples/kdc.conf
/usr/share/doc/krb5-libs-1.15./examples/krb5.conf
/usr/share/doc/python-configobj-4.7./docutils.conf
/usr/share/doc/python-slip-0.4./dbus/example/org.fedoraproject.slip.example.mechanism.conf
/usr/share/doc/python-slip-dbus-0.4./example/org.fedoraproject.slip.example.mechanism.conf
/usr/share/doc/sudo-1.8./examples/pam.conf
/usr/share/doc/sudo-1.8./examples/sudo.conf
/usr/share/doc/sudo-1.8./examples/syslog.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_arp_ping_1.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_arp_ping_2.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_ethtool_1.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_ethtool_2.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_ethtool_3.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_multi_lw_1.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_nsna_ping_1.conf
/usr/share/doc/teamd-1.27/example_configs/activebackup_tipc.conf
/usr/share/doc/teamd-1.27/example_configs/broadcast.conf
/usr/share/doc/teamd-1.27/example_configs/lacp_1.conf
/usr/share/doc/teamd-1.27/example_configs/loadbalance_1.conf
/usr/share/doc/teamd-1.27/example_configs/loadbalance_2.conf
/usr/share/doc/teamd-1.27/example_configs/loadbalance_3.conf
/usr/share/doc/teamd-1.27/example_configs/random.conf
/usr/share/doc/teamd-1.27/example_configs/roundrobin.conf
/usr/share/doc/teamd-1.27/example_configs/roundrobin_2.conf
/usr/share/doc/wpa_supplicant-2.6/wpa_supplicant.conf
/usr/share/doc/wpa_supplicant-2.6/examples/ieee8021x.conf
/usr/share/doc/wpa_supplicant-2.6/examples/openCryptoki.conf
/usr/share/doc/wpa_supplicant-2.6/examples/plaintext.conf
/usr/share/doc/wpa_supplicant-2.6/examples/udhcpd-p2p.conf
/usr/share/doc/wpa_supplicant-2.6/examples/wep.conf
/usr/share/doc/wpa_supplicant-2.6/examples/wpa-psk-tkip.conf
/usr/share/doc/wpa_supplicant-2.6/examples/wpa2-eap-ccmp.conf
/usr/src/kernels/3.10.-.el7.x86_64/include/config/auto.conf
/usr/src/kernels/3.10.-.el7.x86_64/include/config/tristate.conf
/var/lib/NetworkManager/NetworkManager-intern.conf
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# locate -r "\.conf$"          #之匹配以".conf"结尾的文件

7>.查看locate命令的帮助信息

[root@node101.yinzhengjie.org.cn ~]# locate --help
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database. -A, --all only print entries that match all patterns
-b, --basename match only the base name of path names
-c, --count only print number of found entries
-d, --database DBPATH use DBPATH instead of default database (which is
/var/lib/mlocate/mlocate.db)
-e, --existing only print entries for currently existing files
-L, --follow follow trailing symbolic links when checking file
existence (default)
-h, --help print this help
-i, --ignore-case ignore case distinctions when matching patterns
-l, --limit, -n LIMIT limit output (or counting) to LIMIT entries
-m, --mmap ignored, for backward compatibility
-P, --nofollow, -H don't follow trailing symbolic links when checking file
existence
-, --null separate entries with NUL on output
-S, --statistics don't search for entries, print statistics about each
used database
-q, --quiet report no error messages about reading databases
-r, --regexp REGEXP search for basic regexp REGEXP instead of patterns
--regex patterns are extended regexps
-s, --stdio ignored, for backward compatibility
-V, --version print version information
-w, --wholename match whole path name (default) Report bugs to mitr@redhat.com.
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# locate --help

二.实时查找find工具

实时查找工具,通过遍历指定路径完成文件查找 

工作特点:
  (1)查找速度略慢
  (2)精确查找
  (3)实时查找
  (4)可能只搜索用户具备读取和执行权限的目录 语法:
  find [OPTION]... [查找路径] [查找条件] [处理动作]
  查找路径:
      指定具体目标路径;默认为当前目录
    查找条件:
      指定的查找标准,可以文件名、大小、类型、权限等标准进行; 默认为找出指定路径下的所有文件
  处理动作:
      对符合条件的文件做操作,默认输出至屏幕

1>.查看find命令的帮助信息

[root@node101.yinzhengjie.org.cn ~]# find --help
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions: operators (decreasing precedence; -and is implicit where no others are given):
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2
EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2 positional options (always true): -daystart -follow -regextype normal options (always true, specified before other expressions):
-depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
--version -xautofs -xdev -ignore_readdir_race -noignore_readdir_race tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
-nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN
-readable -writable -executable
-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
-used N -user NAME -xtype [bcdpfls]
-context CONTEXT actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
-fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
-exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
-execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ; Report (and track progress on fixing) bugs via the findutils bug-reporting
page at http://savannah.gnu.org/ or, if you have no web access, by sending
email to <bug-findutils@gnu.org>.
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find --help

2>.不指定查找路径,条件和处理动作默认递归查找查找当前目录的所有文件

[root@node101.yinzhengjie.org.cn ~]# find
.
./.lesshst
./a
./a/a
./a/f2.log
./a/mv
./.bash_profile
./.tcshrc
./.cshrc
./.viminfo
./.bash_logout
./.bash_history
./.pki
./.pki/nssdb
./.bashrc
./.mysql_history
./f1.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ls -aR
.:
. .. a .bash_history .bash_logout .bash_profile .bashrc .cshrc f1.log .lesshst .mysql_history .pki .tcshrc .viminfo ./a:
. .. a f2.log mv ./.pki:
. .. nssdb ./.pki/nssdb:
. ..
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find

3>.查找指定路径下的所有文件

[root@node101.yinzhengjie.org.cn ~]# ll -R test/
test/:
total
-rw-r--r-- root root Dec : a
-rw-r--r-- root root Dec : f2.log
-rw-r--r-- root root Dec : mv
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find test/
test/
test/a
test/f2.log
test/mv
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find test/

4>.指定搜索层级

[root@node101.yinzhengjie.org.cn ~]# find / -maxdepth         #表示在根目录开始查找文件,最大搜索目录深度为1。
/
/media
/mnt
/lost+found
/dev
/tmp
/home
/run
/srv
/boot
/bin
/sbin
/lib64
/usr
/sys
/etc
/var
/lib
/proc
/opt
/root
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find / -maxdepth 1                 #表示在根目录开始查找文件,最大搜索目录深度为1。

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -maxdepth
/etc/pki/
/etc/pki/CA
/etc/pki/nss-legacy
/etc/pki/ca-trust
/etc/pki/rsyslog
/etc/pki/nssdb
/etc/pki/rpm-gpg
/etc/pki/tls
/etc/pki/java
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -maxdepth 1            #同上,表示从"/etc/pki"目录开始查找文件,最大搜索深度为1。

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -mindepth
/etc/pki/CA
/etc/pki/CA/newcerts
/etc/pki/CA/private
/etc/pki/CA/crl
/etc/pki/CA/certs
/etc/pki/nss-legacy
/etc/pki/nss-legacy/nss-rhel7.config
/etc/pki/ca-trust
/etc/pki/ca-trust/ca-legacy.conf
/etc/pki/ca-trust/README
/etc/pki/ca-trust/source
/etc/pki/ca-trust/source/anchors
/etc/pki/ca-trust/source/blacklist
/etc/pki/ca-trust/source/ca-bundle.legacy.crt
/etc/pki/ca-trust/source/README
/etc/pki/ca-trust/extracted
/etc/pki/ca-trust/extracted/README
/etc/pki/ca-trust/extracted/pem
/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/README
/etc/pki/ca-trust/extracted/openssl
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/extracted/openssl/README
/etc/pki/ca-trust/extracted/java
/etc/pki/ca-trust/extracted/java/cacerts
/etc/pki/ca-trust/extracted/java/README
/etc/pki/rsyslog
/etc/pki/nssdb
/etc/pki/nssdb/cert9.db
/etc/pki/nssdb/secmod.db
/etc/pki/nssdb/key3.db
/etc/pki/nssdb/key4.db
/etc/pki/nssdb/pkcs11.txt
/etc/pki/nssdb/cert8.db
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-
/etc/pki/tls
/etc/pki/tls/private
/etc/pki/tls/misc
/etc/pki/tls/misc/CA
/etc/pki/tls/misc/c_issuer
/etc/pki/tls/misc/c_info
/etc/pki/tls/misc/c_hash
/etc/pki/tls/misc/c_name
/etc/pki/tls/certs
/etc/pki/tls/certs/ca-bundle.crt
/etc/pki/tls/certs/Makefile
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
/etc/pki/tls/openssl.cnf
/etc/pki/tls/cert.pem
/etc/pki/java
/etc/pki/java/cacerts
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -mindepth 1            #和上面相反,表示最小深度为1,即贪婪搜索,一般情况下就是递归搜索"/etc/pki"目录下但所有文件

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -mindepth  -maxdepth
/etc/pki/ca-trust/source/anchors
/etc/pki/ca-trust/source/blacklist
/etc/pki/ca-trust/source/ca-bundle.legacy.crt
/etc/pki/ca-trust/source/README
/etc/pki/ca-trust/extracted/README
/etc/pki/ca-trust/extracted/pem
/etc/pki/ca-trust/extracted/openssl
/etc/pki/ca-trust/extracted/java
/etc/pki/tls/misc/CA
/etc/pki/tls/misc/c_issuer
/etc/pki/tls/misc/c_info
/etc/pki/tls/misc/c_hash
/etc/pki/tls/misc/c_name
/etc/pki/tls/certs/ca-bundle.crt
/etc/pki/tls/certs/Makefile
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -mindepth 3 -maxdepth 3     #只搜索第三级目录

5>.先处理目录内的文件,再处理指定目录

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -depth         #先处理目录内的文件,再处理指定目录,即先显示文件,后显示文件夹
/etc/pki/CA/newcerts
/etc/pki/CA/private
/etc/pki/CA/crl
/etc/pki/CA/certs
/etc/pki/CA
/etc/pki/nss-legacy/nss-rhel7.config
/etc/pki/nss-legacy
/etc/pki/ca-trust/ca-legacy.conf
/etc/pki/ca-trust/README
/etc/pki/ca-trust/source/anchors
/etc/pki/ca-trust/source/blacklist
/etc/pki/ca-trust/source/ca-bundle.legacy.crt
/etc/pki/ca-trust/source/README
/etc/pki/ca-trust/source
/etc/pki/ca-trust/extracted/README
/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/README
/etc/pki/ca-trust/extracted/pem
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/extracted/openssl/README
/etc/pki/ca-trust/extracted/openssl
/etc/pki/ca-trust/extracted/java/cacerts
/etc/pki/ca-trust/extracted/java/README
/etc/pki/ca-trust/extracted/java
/etc/pki/ca-trust/extracted
/etc/pki/ca-trust
/etc/pki/rsyslog
/etc/pki/nssdb/cert9.db
/etc/pki/nssdb/secmod.db
/etc/pki/nssdb/key3.db
/etc/pki/nssdb/key4.db
/etc/pki/nssdb/pkcs11.txt
/etc/pki/nssdb/cert8.db
/etc/pki/nssdb
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-
/etc/pki/rpm-gpg
/etc/pki/tls/private
/etc/pki/tls/misc/CA
/etc/pki/tls/misc/c_issuer
/etc/pki/tls/misc/c_info
/etc/pki/tls/misc/c_hash
/etc/pki/tls/misc/c_name
/etc/pki/tls/misc
/etc/pki/tls/certs/ca-bundle.crt
/etc/pki/tls/certs/Makefile
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
/etc/pki/tls/certs
/etc/pki/tls/openssl.cnf
/etc/pki/tls/cert.pem
/etc/pki/tls
/etc/pki/java/cacerts
/etc/pki/java
/etc/pki/
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ -depth             #先处理目录内的文件,再处理指定目录,即先显示文件,后显示文件夹

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/     #默认先显示文件夹,后显示文件
/etc/pki/
/etc/pki/CA
/etc/pki/CA/newcerts
/etc/pki/CA/private
/etc/pki/CA/crl
/etc/pki/CA/certs
/etc/pki/nss-legacy
/etc/pki/nss-legacy/nss-rhel7.config
/etc/pki/ca-trust
/etc/pki/ca-trust/ca-legacy.conf
/etc/pki/ca-trust/README
/etc/pki/ca-trust/source
/etc/pki/ca-trust/source/anchors
/etc/pki/ca-trust/source/blacklist
/etc/pki/ca-trust/source/ca-bundle.legacy.crt
/etc/pki/ca-trust/source/README
/etc/pki/ca-trust/extracted
/etc/pki/ca-trust/extracted/README
/etc/pki/ca-trust/extracted/pem
/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/README
/etc/pki/ca-trust/extracted/openssl
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/extracted/openssl/README
/etc/pki/ca-trust/extracted/java
/etc/pki/ca-trust/extracted/java/cacerts
/etc/pki/ca-trust/extracted/java/README
/etc/pki/rsyslog
/etc/pki/nssdb
/etc/pki/nssdb/cert9.db
/etc/pki/nssdb/secmod.db
/etc/pki/nssdb/key3.db
/etc/pki/nssdb/key4.db
/etc/pki/nssdb/pkcs11.txt
/etc/pki/nssdb/cert8.db
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-
/etc/pki/tls
/etc/pki/tls/private
/etc/pki/tls/misc
/etc/pki/tls/misc/CA
/etc/pki/tls/misc/c_issuer
/etc/pki/tls/misc/c_info
/etc/pki/tls/misc/c_hash
/etc/pki/tls/misc/c_name
/etc/pki/tls/certs
/etc/pki/tls/certs/ca-bundle.crt
/etc/pki/tls/certs/Makefile
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
/etc/pki/tls/openssl.cnf
/etc/pki/tls/cert.pem
/etc/pki/java
/etc/pki/java/cacerts
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/                 #默认先显示文件夹,后显示文件

6>.根据文件名和inode查找

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name ifcfg-eth0          #文件名称必须要精确匹配
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name ifcfg              #不存在叫ifcfg的文件,因此匹配不上
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name ifcfg-eth0          #文件名称必须要精确匹配

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name ifcfg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "ifcfg*"            #支持使用glob,即通配符
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-lo
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "ifcfg*"            #支持使用glob,即通配符

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name IFCFG-ETH0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -iname IFCFG-ETH0          #忽略匹配的文件名称大小写
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -iname IFCFG-ETH0          #忽略匹配的文件名称大小写

[root@node101.yinzhengjie.org.cn ~]# ll -i /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. root root Sep : /etc/sysconfig/network-scripts/ifcfg-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ln /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcf-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r--. root root Sep : ifcf-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find / -inum               #基于inode节点编号查找文件
/etc/sysconfig/network-scripts/ifcfg-eth0
/root/ifcf-eth0
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find / -inum 788769               #基于inode节点编号查找文件

[root@node101.yinzhengjie.org.cn ~]# find / -inum  -ls             #列出查找到到文件
-rw-rw-r-- yinzhengjie yinzhengjie Sep : /home/yinzhengjie/.pyenv/versions/3.6./envs/jason/lib/python3./site-packages/notebook/static/components/MathJax/extensions/a11y/mathmaps/es/symbols/math_non_characters.js
--w------- root root Dec : /sys/bus/memory/uevent
-rw-r--r-- root root Dec : /sys/kernel/debug/tracing/function_profile_enabled
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find / -inum 64 -ls                #列出查找到到文件

[root@node101.yinzhengjie.org.cn ~]# ll -i /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. root root Sep : /etc/sysconfig/network-scripts/ifcfg-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -i
total
-rw-r--r--. root root Sep : ifcf-eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -samefile /root/ifcf-eth0  #在"/etc"目录下找和"/root/ifcf-eth0"文件相同的文件,即是硬连接关系而非inode节点编号一样,inode节点编号一样可能是不同分区的文件哟,而硬连接是不可以跨越分区的。
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -samefile /root/ifcf-eth0      #在"/etc"目录下找和"/root/ifcf-eth0"文件相同的文件,即是硬连接关系而非inode节点编号一样,inode节点编号一样可能是不同分区的文件哟,而硬连接是不可以跨越分区的。

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -links  -ls              #在"/etc"目录下查看链接数为6的文件
drwxr-xr-x root root Dec : /etc/sysconfig
drwxr-xr-x root root Sep : /etc/lvm
drwxr-xr-x root root Mar /etc/pki/CA
drwxr-xr-x root root Sep : /etc/security
drwxr-xr-x root root Sep : /etc/yum
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -links 6 -ls              #在"/etc"目录下查看链接数为6的文件

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -regex ".*\.sh$"            #在"/etc"目录下查看以".sh"结尾的文件名称,注意,find和locate不同,find的正则表达式要求咱们匹配文件的全路径。
/etc/kernel/postinst.d/-dracut-rescue-postinst.sh
/etc/profile.d/less.sh
/etc/profile.d/which2.sh
/etc/profile.d/256term.sh
/etc/profile.d/vim.sh
/etc/profile.d/colorgrep.sh
/etc/profile.d/colorls.sh
/etc/profile.d/lang.sh
/etc/dhcp/dhclient.d/chrony.sh
/etc/dhcp/dhclient-exit-hooks.d/azure-cloud.sh
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -regex ".*\.sh$"            #在"/etc"目录下查看以".sh"结尾的文件名称,注意,find和locate不同,find的正则表达式要求咱们匹配文件的全路径。

7>.根据属主、属组查找

-user USERNAME:
  查找属主为指定用户(UID)的文件 -group GRPNAME:
  查找属组为指定组(GID)的文件 -uid UserID:
  查找属主为指定的UID号的文件
-gid GroupID:
  查找属组为指定的GID号的文件 -nouser:
  查找没有属主的文件 -nogroup:
  查找没有属组的文件 
[root@node101.yinzhengjie.org.cn ~]# find /home/yinzhengjie/devops/ -user yinzhengjie -ls        #查找属主为yinzhengjie的文件
drwxrwxr-x yinzhengjie yinzhengjie Sep : /home/yinzhengjie/devops/
drwxrwxr-x yinzhengjie yinzhengjie Sep : /home/yinzhengjie/devops/op
-rw-rw-r-- yinzhengjie yinzhengjie Sep : /home/yinzhengjie/devops/op/.python-version
drwxrwxr-x yinzhengjie yinzhengjie Sep : /home/yinzhengjie/devops/cmdb
-rw-rw-r-- yinzhengjie yinzhengjie Sep : /home/yinzhengjie/devops/cmdb/.python-version
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /home/yinzhengjie/devops/ -user yinzhengjie -ls        #查找属主为yinzhengjie的文件

[root@node101.yinzhengjie.org.cn ~]# useradd centos
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# su -l centos
[centos@node101.yinzhengjie.org.cn ~]$
[centos@node101.yinzhengjie.org.cn ~]$ touch /tmp/a{..}.txt
[centos@node101.yinzhengjie.org.cn ~]$
[centos@node101.yinzhengjie.org.cn ~]$ ll /tmp/
total
-rw-rw-r-- centos centos Dec : a1.txt
-rw-rw-r-- centos centos Dec : a2.txt
-rw-rw-r-- centos centos Dec : a3.txt
[centos@node101.yinzhengjie.org.cn ~]$
[centos@node101.yinzhengjie.org.cn ~]$ exit
logout
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# userdel -r centos
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /tmp/
total
-rw-rw-r-- Dec : a1.txt
-rw-rw-r-- Dec : a2.txt
-rw-rw-r-- Dec : a3.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /tmp/ -nouser -ls            #查看没有属主的文件
-rw-rw-r-- Dec : /tmp/a1.txt
-rw-rw-r-- Dec : /tmp/a2.txt
-rw-rw-r-- Dec : /tmp/a3.txt
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /tmp/ -nouser -ls                          #查看没有属主的文件

[root@node101.yinzhengjie.org.cn ~]# find /tmp/ -nogroup -ls                          #查看没有属组的文件
-rw-rw-r-- Dec : /tmp/a1.txt
-rw-rw-r-- Dec : /tmp/a2.txt
-rw-rw-r-- Dec : /tmp/a3.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /tmp/ -nogroup -ls                          #查看没有属组的文件

8>.根据文件类型查找

-type TYPE
  f: 普通文件
  d: 目录文件
  l: 符号链接文件
  s:套接字文件
  b: 块设备文件
  c: 字符设备文件
  p: 管道文件
[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type d
/etc/selinux/
/etc/selinux/tmp
/etc/selinux/targeted
/etc/selinux/targeted/contexts
/etc/selinux/targeted/contexts/files
/etc/selinux/targeted/contexts/users
/etc/selinux/targeted/active
/etc/selinux/targeted/active/modules
/etc/selinux/targeted/active/modules/disabled
/etc/selinux/targeted/active/modules/
/etc/selinux/targeted/active/modules//rdisc
/etc/selinux/targeted/active/modules//tuned
/etc/selinux/targeted/active/modules//setroubleshoot
/etc/selinux/targeted/active/modules//wireshark
/etc/selinux/targeted/active/modules//permissivedomains
/etc/selinux/targeted/active/modules//prelude
/etc/selinux/targeted/active/modules//apcupsd
/etc/selinux/targeted/active/modules//courier
/etc/selinux/targeted/active/modules//nut
/etc/selinux/targeted/active/modules//bacula
/etc/selinux/targeted/active/modules//pwauth
/etc/selinux/targeted/active/modules//certwatch
/etc/selinux/targeted/active/modules//ipa
/etc/selinux/targeted/active/modules//tcsd
/etc/selinux/targeted/active/modules//sensord
/etc/selinux/targeted/active/modules//uucp
/etc/selinux/targeted/active/modules//mrtg
/etc/selinux/targeted/active/modules//kerberos
/etc/selinux/targeted/active/modules//firewalld
/etc/selinux/targeted/active/modules//kmscon
/etc/selinux/targeted/active/modules//sandboxX
/etc/selinux/targeted/active/modules//loadkeys
/etc/selinux/targeted/active/modules//smsd
/etc/selinux/targeted/active/modules//zarafa
/etc/selinux/targeted/active/modules//tftp
/etc/selinux/targeted/active/modules//hsqldb
/etc/selinux/targeted/active/modules//chronyd
/etc/selinux/targeted/active/modules//oracleasm
/etc/selinux/targeted/active/modules//vdagent
/etc/selinux/targeted/active/modules//ntop
/etc/selinux/targeted/active/modules//lockdev
/etc/selinux/targeted/active/modules//stapserver
/etc/selinux/targeted/active/modules//wdmd
/etc/selinux/targeted/active/modules//prosody
/etc/selinux/targeted/active/modules//aiccu
/etc/selinux/targeted/active/modules//ajaxterm
/etc/selinux/targeted/active/modules//guest
/etc/selinux/targeted/active/modules//publicfile
/etc/selinux/targeted/active/modules//nscd
/etc/selinux/targeted/active/modules//netlabel
/etc/selinux/targeted/active/modules//userhelper
/etc/selinux/targeted/active/modules//ntp
/etc/selinux/targeted/active/modules//portreserve
/etc/selinux/targeted/active/modules//cockpit
/etc/selinux/targeted/active/modules//isns
/etc/selinux/targeted/active/modules//callweaver
/etc/selinux/targeted/active/modules//rhgb
/etc/selinux/targeted/active/modules//gpsd
/etc/selinux/targeted/active/modules//realmd
/etc/selinux/targeted/active/modules//cachefilesd
/etc/selinux/targeted/active/modules//portmap
/etc/selinux/targeted/active/modules//mock
/etc/selinux/targeted/active/modules//freeipmi
/etc/selinux/targeted/active/modules//logging
/etc/selinux/targeted/active/modules//squid
/etc/selinux/targeted/active/modules//blkmapd
/etc/selinux/targeted/active/modules//mojomojo
/etc/selinux/targeted/active/modules//bcfg2
/etc/selinux/targeted/active/modules//miscfiles
/etc/selinux/targeted/active/modules//calamaris
/etc/selinux/targeted/active/modules//keystone
/etc/selinux/targeted/active/modules//vlock
/etc/selinux/targeted/active/modules//ipmievd
/etc/selinux/targeted/active/modules//rhsmcertd
/etc/selinux/targeted/active/modules//qmail
/etc/selinux/targeted/active/modules//cinder
/etc/selinux/targeted/active/modules//lircd
/etc/selinux/targeted/active/modules//snapper
/etc/selinux/targeted/active/modules//cmirrord
/etc/selinux/targeted/active/modules//xguest
/etc/selinux/targeted/active/modules//rkhunter
/etc/selinux/targeted/active/modules//ctdb
/etc/selinux/targeted/active/modules//thumb
/etc/selinux/targeted/active/modules//ncftool
/etc/selinux/targeted/active/modules//pingd
/etc/selinux/targeted/active/modules//finger
/etc/selinux/targeted/active/modules//inn
/etc/selinux/targeted/active/modules//lvm
/etc/selinux/targeted/active/modules//certmonger
/etc/selinux/targeted/active/modules//dbus
/etc/selinux/targeted/active/modules//cfengine
/etc/selinux/targeted/active/modules//daemontools
/etc/selinux/targeted/active/modules//mysql
/etc/selinux/targeted/active/modules//iptables
/etc/selinux/targeted/active/modules//mta
/etc/selinux/targeted/active/modules//w3c
/etc/selinux/targeted/active/modules//denyhosts
/etc/selinux/targeted/active/modules//cgroup
/etc/selinux/targeted/active/modules//sbd
/etc/selinux/targeted/active/modules//pki
/etc/selinux/targeted/active/modules//cyrus
/etc/selinux/targeted/active/modules//mon_statd
/etc/selinux/targeted/active/modules//rtkit
/etc/selinux/targeted/active/modules//rpm
/etc/selinux/targeted/active/modules//dbadm
/etc/selinux/targeted/active/modules//stunnel
/etc/selinux/targeted/active/modules//firstboot
/etc/selinux/targeted/active/modules//zebra
/etc/selinux/targeted/active/modules//certmaster
/etc/selinux/targeted/active/modules//apm
/etc/selinux/targeted/active/modules//drbd
/etc/selinux/targeted/active/modules//pads
/etc/selinux/targeted/active/modules//brctl
/etc/selinux/targeted/active/modules//quantum
/etc/selinux/targeted/active/modules//soundserver
/etc/selinux/targeted/active/modules//openct
/etc/selinux/targeted/active/modules//procmail
/etc/selinux/targeted/active/modules//mailscanner
/etc/selinux/targeted/active/modules//plymouthd
/etc/selinux/targeted/active/modules//slpd
/etc/selinux/targeted/active/modules//irc
/etc/selinux/targeted/active/modules//webadm
/etc/selinux/targeted/active/modules//zoneminder
/etc/selinux/targeted/active/modules//geoclue
/etc/selinux/targeted/active/modules//sblim
/etc/selinux/targeted/active/modules//container
/etc/selinux/targeted/active/modules//antivirus
/etc/selinux/targeted/active/modules//wine
/etc/selinux/targeted/active/modules//openshift
/etc/selinux/targeted/active/modules//mplayer
/etc/selinux/targeted/active/modules//bluetooth
/etc/selinux/targeted/active/modules//swift
/etc/selinux/targeted/active/modules//dhcp
/etc/selinux/targeted/active/modules//dbskk
/etc/selinux/targeted/active/modules//entropyd
/etc/selinux/targeted/active/modules//tvtime
/etc/selinux/targeted/active/modules//cvs
/etc/selinux/targeted/active/modules//brltty
/etc/selinux/targeted/active/modules//kdumpgui
/etc/selinux/targeted/active/modules//postfix
/etc/selinux/targeted/active/modules//postgresql
/etc/selinux/targeted/active/modules//getty
/etc/selinux/targeted/active/modules//slocate
/etc/selinux/targeted/active/modules//amanda
/etc/selinux/targeted/active/modules//sysstat
/etc/selinux/targeted/active/modules//fetchmail
/etc/selinux/targeted/active/modules//milter
/etc/selinux/targeted/active/modules//sasl
/etc/selinux/targeted/active/modules//lldpad
/etc/selinux/targeted/active/modules//rhcs
/etc/selinux/targeted/active/modules//logwatch
/etc/selinux/targeted/active/modules//gitosis
/etc/selinux/targeted/active/modules//qpid
/etc/selinux/targeted/active/modules//sectoolm
/etc/selinux/targeted/active/modules//nx
/etc/selinux/targeted/active/modules//hostname
/etc/selinux/targeted/active/modules//shorewall
/etc/selinux/targeted/active/modules//sysadm
/etc/selinux/targeted/active/modules//rpcbind
/etc/selinux/targeted/active/modules//openwsman
/etc/selinux/targeted/active/modules//netutils
/etc/selinux/targeted/active/modules//condor
/etc/selinux/targeted/active/modules//auditadm
/etc/selinux/targeted/active/modules//fstools
/etc/selinux/targeted/active/modules//smokeping
/etc/selinux/targeted/active/modules//nsd
/etc/selinux/targeted/active/modules//irqbalance
/etc/selinux/targeted/active/modules//rshd
/etc/selinux/targeted/active/modules//vmware
/etc/selinux/targeted/active/modules//pcp
/etc/selinux/targeted/active/modules//pcmcia
/etc/selinux/targeted/active/modules//tomcat
/etc/selinux/targeted/active/modules//sge
/etc/selinux/targeted/active/modules//openvswitch
/etc/selinux/targeted/active/modules//games
/etc/selinux/targeted/active/modules//sssd
/etc/selinux/targeted/active/modules//setrans
/etc/selinux/targeted/active/modules//devicekit
/etc/selinux/targeted/active/modules//mythtv
/etc/selinux/targeted/active/modules//podsleuth
/etc/selinux/targeted/active/modules//updfstab
/etc/selinux/targeted/active/modules//opendnssec
/etc/selinux/targeted/active/modules//mirrormanager
/etc/selinux/targeted/active/modules//zabbix
/etc/selinux/targeted/active/modules//xserver
/etc/selinux/targeted/active/modules//zosremote
/etc/selinux/targeted/active/modules//cdrecord
/etc/selinux/targeted/active/modules//radius
/etc/selinux/targeted/active/modules//ktalk
/etc/selinux/targeted/active/modules//xen
/etc/selinux/targeted/active/modules//sanlock
/etc/selinux/targeted/active/modules//acct
/etc/selinux/targeted/active/modules//authlogin
/etc/selinux/targeted/active/modules//usbmodules
/etc/selinux/targeted/active/modules//iscsi
/etc/selinux/targeted/active/modules//colord
/etc/selinux/targeted/active/modules//glusterd
/etc/selinux/targeted/active/modules//conman
/etc/selinux/targeted/active/modules//fprintd
/etc/selinux/targeted/active/modules//tlp
/etc/selinux/targeted/active/modules//dnsmasq
/etc/selinux/targeted/active/modules//rwho
/etc/selinux/targeted/active/modules//opensm
/etc/selinux/targeted/active/modules//base
/etc/selinux/targeted/active/modules//rpc
/etc/selinux/targeted/active/modules//speech-dispatcher
/etc/selinux/targeted/active/modules//glance
/etc/selinux/targeted/active/modules//mpd
/etc/selinux/targeted/active/modules//l2tp
/etc/selinux/targeted/active/modules//ulogd
/etc/selinux/targeted/active/modules//gdomap
/etc/selinux/targeted/active/modules//secadm
/etc/selinux/targeted/active/modules//jabber
/etc/selinux/targeted/active/modules//consolekit
/etc/selinux/targeted/active/modules//vmtools
/etc/selinux/targeted/active/modules//dirsrv
/etc/selinux/targeted/active/modules//mozilla
/etc/selinux/targeted/active/modules//rhnsd
/etc/selinux/targeted/active/modules//puppet
/etc/selinux/targeted/active/modules//authconfig
/etc/selinux/targeted/active/modules//gssproxy
/etc/selinux/targeted/active/modules//redis
/etc/selinux/targeted/active/modules//munin
/etc/selinux/targeted/active/modules//nagios
/etc/selinux/targeted/active/modules//cloudform
/etc/selinux/targeted/active/modules//snort
/etc/selinux/targeted/active/modules//ricci
/etc/selinux/targeted/active/modules//awstats
/etc/selinux/targeted/active/modules//su
/etc/selinux/targeted/active/modules//pcscd
/etc/selinux/targeted/active/modules//unprivuser
/etc/selinux/targeted/active/modules//rngd
/etc/selinux/targeted/active/modules//sendmail
/etc/selinux/targeted/active/modules//lsm
/etc/selinux/targeted/active/modules//kismet
/etc/selinux/targeted/active/modules//jetty
/etc/selinux/targeted/active/modules//ninfod
/etc/selinux/targeted/active/modules//rhev
/etc/selinux/targeted/active/modules//ksmtuned
/etc/selinux/targeted/active/modules//firewallgui
/etc/selinux/targeted/active/modules//logrotate
/etc/selinux/targeted/active/modules//pulseaudio
/etc/selinux/targeted/active/modules//memcached
/etc/selinux/targeted/active/modules//ipsec
/etc/selinux/targeted/active/modules//smartmon
/etc/selinux/targeted/active/modules//spamassassin
/etc/selinux/targeted/active/modules//bugzilla
/etc/selinux/targeted/active/modules//udev
/etc/selinux/targeted/active/modules//tangd
/etc/selinux/targeted/active/modules//cpuplug
/etc/selinux/targeted/active/modules//rssh
/etc/selinux/targeted/active/modules//samba
/etc/selinux/targeted/active/modules//fcoe
/etc/selinux/targeted/active/modules//dnssec
/etc/selinux/targeted/active/modules//mount
/etc/selinux/targeted/active/modules//gnome
/etc/selinux/targeted/active/modules//clock
/etc/selinux/targeted/active/modules//hddtemp
/etc/selinux/targeted/active/modules//telepathy
/etc/selinux/targeted/active/modules//raid
/etc/selinux/targeted/active/modules//cobbler
/etc/selinux/targeted/active/modules//roundup
/etc/selinux/targeted/active/modules//apache
/etc/selinux/targeted/active/modules//comsat
/etc/selinux/targeted/active/modules//watchdog
/etc/selinux/targeted/active/modules//varnishd
/etc/selinux/targeted/active/modules//clogd
/etc/selinux/targeted/active/modules//motion
/etc/selinux/targeted/active/modules//virt
/etc/selinux/targeted/active/modules//openvpn
/etc/selinux/targeted/active/modules//arpwatch
/etc/selinux/targeted/active/modules//livecd
/etc/selinux/targeted/active/modules//nslcd
/etc/selinux/targeted/active/modules//thin
/etc/selinux/targeted/active/modules//keyboardd
/etc/selinux/targeted/active/modules//cgdcbxd
/etc/selinux/targeted/active/modules//dictd
/etc/selinux/targeted/active/modules//libraries
/etc/selinux/targeted/active/modules//gpm
/etc/selinux/targeted/active/modules//polipo
/etc/selinux/targeted/active/modules//oddjob
/etc/selinux/targeted/active/modules//usernetctl
/etc/selinux/targeted/active/modules//fail2ban
/etc/selinux/targeted/active/modules//minidlna
/etc/selinux/targeted/active/modules//lttng-tools
/etc/selinux/targeted/active/modules//vhostmd
/etc/selinux/targeted/active/modules//nis
/etc/selinux/targeted/active/modules//tcpd
/etc/selinux/targeted/active/modules//keepalived
/etc/selinux/targeted/active/modules//blueman
/etc/selinux/targeted/active/modules//bind
/etc/selinux/targeted/active/modules//dmesg
/etc/selinux/targeted/active/modules//snmp
/etc/selinux/targeted/active/modules//ppp
/etc/selinux/targeted/active/modules//sosreport
/etc/selinux/targeted/active/modules//accountsd
/etc/selinux/targeted/active/modules//dovecot
/etc/selinux/targeted/active/modules//bumblebee
/etc/selinux/targeted/active/modules//minissdpd
/etc/selinux/targeted/active/modules//uuidd
/etc/selinux/targeted/active/modules//mongodb
/etc/selinux/targeted/active/modules//pesign
/etc/selinux/targeted/active/modules//anaconda
/etc/selinux/targeted/active/modules//modutils
/etc/selinux/targeted/active/modules//cipe
/etc/selinux/targeted/active/modules//ccs
/etc/selinux/targeted/active/modules//osad
/etc/selinux/targeted/active/modules//policykit
/etc/selinux/targeted/active/modules//abrt
/etc/selinux/targeted/active/modules//privoxy
/etc/selinux/targeted/active/modules//psad
/etc/selinux/targeted/active/modules//likewise
/etc/selinux/targeted/active/modules//rsync
/etc/selinux/targeted/active/modules//prelink
/etc/selinux/targeted/active/modules//init
/etc/selinux/targeted/active/modules//targetd
/etc/selinux/targeted/active/modules//mailman
/etc/selinux/targeted/active/modules//unconfineduser
/etc/selinux/targeted/active/modules//mcelog
/etc/selinux/targeted/active/modules//usbmuxd
/etc/selinux/targeted/active/modules//usermanage
/etc/selinux/targeted/active/modules//tmpreaper
/etc/selinux/targeted/active/modules//rasdaemon
/etc/selinux/targeted/active/modules//cyphesis
/etc/selinux/targeted/active/modules//openhpid
/etc/selinux/targeted/active/modules//uml
/etc/selinux/targeted/active/modules//pegasus
/etc/selinux/targeted/active/modules//telnet
/etc/selinux/targeted/active/modules//selinuxutil
/etc/selinux/targeted/active/modules//readahead
/etc/selinux/targeted/active/modules//mediawiki
/etc/selinux/targeted/active/modules//staff
/etc/selinux/targeted/active/modules//cron
/etc/selinux/targeted/active/modules//cpufreqselector
/etc/selinux/targeted/active/modules//nova
/etc/selinux/targeted/active/modules//networkmanager
/etc/selinux/targeted/active/modules//jockey
/etc/selinux/targeted/active/modules//chrome
/etc/selinux/targeted/active/modules//rabbitmq
/etc/selinux/targeted/active/modules//avahi
/etc/selinux/targeted/active/modules//ptchown
/etc/selinux/targeted/active/modules//rtas
/etc/selinux/targeted/active/modules//asterisk
/etc/selinux/targeted/active/modules//svnserve
/etc/selinux/targeted/active/modules//lpd
/etc/selinux/targeted/active/modules//gpg
/etc/selinux/targeted/active/modules//ddclient
/etc/selinux/targeted/active/modules//sysnetwork
/etc/selinux/targeted/active/modules//ftp
/etc/selinux/targeted/active/modules//inetd
/etc/selinux/targeted/active/modules//linuxptp
/etc/selinux/targeted/active/modules//aide
/etc/selinux/targeted/active/modules//postgrey
/etc/selinux/targeted/active/modules//screen
/etc/selinux/targeted/active/modules//mip6d
/etc/selinux/targeted/active/modules//amtu
/etc/selinux/targeted/active/modules//icecast
/etc/selinux/targeted/active/modules//dcc
/etc/selinux/targeted/active/modules//bootloader
/etc/selinux/targeted/active/modules//collectd
/etc/selinux/targeted/active/modules//webalizer
/etc/selinux/targeted/active/modules//iotop
/etc/selinux/targeted/active/modules//freqset
/etc/selinux/targeted/active/modules//passenger
/etc/selinux/targeted/active/modules//man2html
/etc/selinux/targeted/active/modules//dspam
/etc/selinux/targeted/active/modules//obex
/etc/selinux/targeted/active/modules//radvd
/etc/selinux/targeted/active/modules//pkcs
/etc/selinux/targeted/active/modules//journalctl
/etc/selinux/targeted/active/modules//couchdb
/etc/selinux/targeted/active/modules//dmidecode
/etc/selinux/targeted/active/modules//sambagui
/etc/selinux/targeted/active/modules//systemd
/etc/selinux/targeted/active/modules//modemmanager
/etc/selinux/targeted/active/modules//remotelogin
/etc/selinux/targeted/active/modules//namespace
/etc/selinux/targeted/active/modules//openshift-origin
/etc/selinux/targeted/active/modules//exim
/etc/selinux/targeted/active/modules//numad
/etc/selinux/targeted/active/modules//quota
/etc/selinux/targeted/active/modules//bitlbee
/etc/selinux/targeted/active/modules//userdomain
/etc/selinux/targeted/active/modules//iodine
/etc/selinux/targeted/active/modules//application
/etc/selinux/targeted/active/modules//locallogin
/etc/selinux/targeted/active/modules//alsa
/etc/selinux/targeted/active/modules//vpn
/etc/selinux/targeted/active/modules//hwloc
/etc/selinux/targeted/active/modules//dirsrv-admin
/etc/selinux/targeted/active/modules//cups
/etc/selinux/targeted/active/modules//logadm
/etc/selinux/targeted/active/modules//tgtd
/etc/selinux/targeted/active/modules//smoltclient
/etc/selinux/targeted/active/modules//canna
/etc/selinux/targeted/active/modules//unconfined
/etc/selinux/targeted/active/modules//sysadm_secadm
/etc/selinux/targeted/active/modules//vnstatd
/etc/selinux/targeted/active/modules//ldap
/etc/selinux/targeted/active/modules//hypervkvp
/etc/selinux/targeted/active/modules//piranha
/etc/selinux/targeted/active/modules//cpucontrol
/etc/selinux/targeted/active/modules//boinc
/etc/selinux/targeted/active/modules//ssh
/etc/selinux/targeted/active/modules//automount
/etc/selinux/targeted/active/modules//seunshare
/etc/selinux/targeted/active/modules//rlogin
/etc/selinux/targeted/active/modules//tor
/etc/selinux/targeted/active/modules//kdump
/etc/selinux/targeted/active/modules//git
/etc/selinux/targeted/active/modules//mandb
/etc/selinux/targeted/active/modules//afs
/etc/selinux/targeted/active/modules//unlabelednet
/etc/selinux/targeted/active/modules//sudo
/etc/selinux/targeted/modules
/etc/selinux/targeted/modules/active
/etc/selinux/targeted/modules/active/modules
/etc/selinux/targeted/policy
/etc/selinux/targeted/logins
/etc/selinux/final
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type d                #只查看"/etc/selinux"目录下的所有目录

9>.空文件或目录

[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type d -empty
/etc/selinux/tmp
/etc/selinux/targeted/active/modules/disabled
/etc/selinux/targeted/modules/active/modules
/etc/selinux/targeted/logins
/etc/selinux/final
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/targeted/logins
total
[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type d -empty
/etc/selinux/tmp
/etc/selinux/targeted/active/modules/disabled
/etc/selinux/targeted/modules/active/modules
/etc/selinux/targeted/logins
/etc/selinux/final
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/tmp
total
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/targeted/active/modules/disabled
total
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/targeted/modules/active/modules
total
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/targeted/logins
total
[root@node101.yinzhengjie.org.cn ~]# ll /etc/selinux/final
total
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type d -empty          #只查看"/etc/selinux"目录下的所有空目录

[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type f -empty
/etc/selinux/targeted/contexts/files/file_contexts.subs
/etc/selinux/targeted/semanage.trans.LOCK
/etc/selinux/targeted/semanage.read.LOCK
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/selinux/targeted/contexts/files/file_contexts.subs
[root@node101.yinzhengjie.org.cn ~]# cat /etc/selinux/targeted/semanage.trans.LOCK
[root@node101.yinzhengjie.org.cn ~]# cat /etc/selinux/targeted/semanage.read.LOCK
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/selinux/ -type f -empty          #只查看"/etc/selinux"目录下的所有空文件

10>.组合查找

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user root        #在"/etc"目录下查找以".sh"结尾,而且用户名是root的文件,这是逻辑与的关系。
/etc/kernel/postinst.d/-dracut-rescue-postinst.sh
/etc/profile.d/less.sh
/etc/profile.d/which2.sh
/etc/profile.d/256term.sh
/etc/profile.d/vim.sh
/etc/profile.d/colorgrep.sh
/etc/profile.d/colorls.sh
/etc/profile.d/lang.sh
/etc/dhcp/dhclient.d/chrony.sh
/etc/dhcp/dhclient-exit-hooks.d/azure-cloud.sh
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -user root             #匹配多个条件时默认就是逻辑与的关系
/etc/kernel/postinst.d/-dracut-rescue-postinst.sh
/etc/profile.d/less.sh
/etc/profile.d/which2.sh
/etc/profile.d/256term.sh
/etc/profile.d/vim.sh
/etc/profile.d/colorgrep.sh
/etc/profile.d/colorls.sh
/etc/profile.d/lang.sh
/etc/dhcp/dhclient.d/chrony.sh
/etc/dhcp/dhclient-exit-hooks.d/azure-cloud.sh
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -user root | wc -l [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user root | wc -l [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user root        #在"/etc"目录下查找以".sh"结尾,而且用户名是root的文件,这是逻辑与的关系。

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user apache
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -o -user apache        #在"/etc"目录下查找以".sh"结尾,或者用户名是apache的文件,这是逻辑或的关系。
/etc/kernel/postinst.d/-dracut-rescue-postinst.sh
/etc/profile.d/less.sh
/etc/profile.d/which2.sh
/etc/profile.d/256term.sh
/etc/profile.d/vim.sh
/etc/profile.d/colorgrep.sh
/etc/profile.d/colorls.sh
/etc/profile.d/lang.sh
/etc/dhcp/dhclient.d/chrony.sh
/etc/dhcp/dhclient-exit-hooks.d/azure-cloud.sh
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -o -user apache        #在"/etc"目录下查找以".sh"结尾,或者用户名是apache的文件,这是逻辑或的关系。

[root@node101.yinzhengjie.org.cn ~]# ll /etc/pki/ca-trust/
total
-rw-r--r--. root root May ca-legacy.conf
drwxr-xr-x. root root Sep : extracted
-rw-r--r--. root root May README
drwxr-xr-x. root root Sep : source
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ca-trust/ ! -name "*.conf" #查找"/etc/pki/ca-trust"不是以".conf"结尾的文件或目录。
/etc/pki/ca-trust/
/etc/pki/ca-trust/README
/etc/pki/ca-trust/source
/etc/pki/ca-trust/source/anchors
/etc/pki/ca-trust/source/blacklist
/etc/pki/ca-trust/source/ca-bundle.legacy.crt
/etc/pki/ca-trust/source/README
/etc/pki/ca-trust/extracted
/etc/pki/ca-trust/extracted/README
/etc/pki/ca-trust/extracted/pem
/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/README
/etc/pki/ca-trust/extracted/openssl
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/extracted/openssl/README
/etc/pki/ca-trust/extracted/java
/etc/pki/ca-trust/extracted/java/cacerts
/etc/pki/ca-trust/extracted/java/README
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/pki/ca-trust/ ! -name "*.conf"       #查找"/etc/pki/ca-trust"不是以".conf"结尾的文件或目录。

11>.德·摩根定律

(非 A)或 (非 B) = 非(A 且 B)
(非 A)且 (非 B) = 非(A 或 B) 示例:
!A -a !B = !(A -o B)
!A -o !B = !(A -a B)
[root@node101.yinzhengjie.org.cn ~]# mkdir /etc/yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chown yinzhengjie /etc/yinzhengjie/
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# su -l yinzhengjie
Last login: Mon Sep :: EDT on pts/
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ touch a{..}.txt
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ touch /etc/yinzhengjie/httpd{..}.conf
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ echo "yinzhengjie.org.cn" > /etc/yinzhengjie/domain.info
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ ll /etc/yinzhengjie/
total
-rw-rw-r-- yinzhengjie yinzhengjie Dec : domain.info
-rw-rw-r-- yinzhengjie yinzhengjie Dec : httpd1.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : httpd2.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : httpd3.conf
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ exit
logout
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not \( -user root -o -user apache \)        #在"/etc"目录下找到属主不是root或者apache的文件
/etc/polkit-/rules.d
/etc/yinzhengjie
/etc/yinzhengjie/httpd3.conf
/etc/yinzhengjie/httpd1.conf
/etc/yinzhengjie/httpd2.conf
/etc/yinzhengjie/domain.info
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not \( -user root -o -user apache \) -ls
drwx------ polkitd root Sep : /etc/polkit-/rules.d
drwxr-xr-x yinzhengjie root Dec : /etc/yinzhengjie
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd3.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd1.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd2.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/domain.info
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not \( -user root -o -user apache \) | wc -l [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not \( -user root -o -user apache \)        #在"/etc"目录下找到属主不是root或者apache的文件

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user  root  -a -not -user  apache                   #在"/etc"目录下递归查找属主不是root而且属主也不是apache的所有文件
/etc/polkit-/rules.d
/etc/yinzhengjie
/etc/yinzhengjie/httpd3.conf
/etc/yinzhengjie/httpd1.conf
/etc/yinzhengjie/httpd2.conf
/etc/yinzhengjie/domain.info
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user root -a -not -user apache | wc -l     [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user root -a -not -user apache -ls
drwx------ polkitd root Sep : /etc/polkit-/rules.d
drwxr-xr-x yinzhengjie root Dec : /etc/yinzhengjie
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd3.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd1.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/httpd2.conf
-rw-rw-r-- yinzhengjie yinzhengjie Dec : /etc/yinzhengjie/domain.info
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user root -a -not -user apache         #和上面的功能一样,在"/etc"目录下递归查找属主不是root而且属主也不是apache的所有文件

12>.根据文件大小来查找 

-size [+|-]#UNIT
  常用单位:
    k, M, G,c(byte)
  #UNIT: (#-, #]
    如:6k 表示(5k,6k],即查找大于5k小于等于6k的文件。
  -#UNIT:[,#-]
    如:-6k 表示[,6k],即查找小于6k的文件。
  +#UNIT:(#,∞)
    如:+6k 表示(6k,∞),即查找大于6k的文件。 
[root@node101.yinzhengjie.org.cn ~]# dd if=/dev/zero of=a.txt bs=1K count=
+ records in
+ records out
bytes ( kB) copied, 0.000461065 s, 22.2 MB/s
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# dd if=/dev/zero of=b.txt bs=1K count=
+ records in
+ records out
bytes (9.2 kB) copied, 0.000257093 s, 35.8 MB/s
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# dd if=/dev/zero of=c.txt bs=1K count=
+ records in
+ records out
bytes ( kB) copied, 0.000290539 s, 38.8 MB/s
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# dd if=/dev/zero of=d4.txt bs=1K count=
+ records in
+ records out
bytes (9.2 kB) copied, 0.000514858 s, 17.9 MB/s
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : a.txt
-rw-r--r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -h
total 48K
-rw-r--r-- root root 10K Dec : a.txt
-rw-r--r-- root root .0K Dec : b.txt
-rw-r--r-- root root 11K Dec : c.txt
-rw-r--r-- root root .0K Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -size 10k
./a.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo >> b.txt       #追加换行符"\n",即增加一个字节。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : a.txt
-rw-r--r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -h
total 48K
-rw-r--r-- root root 10K Dec : a.txt
-rw-r--r-- root root .1K Dec : b.txt
-rw-r--r-- root root 11K Dec : c.txt
-rw-r--r-- root root .0K Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -size 10k
./a.txt
./b.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -size 10k -ls        #注意,size命令是模糊匹配,即匹配10k表示大于9k小于等于10k的文件。
-rw-r--r-- root root Dec : ./a.txt
-rw-r--r-- root root Dec : ./b.txt
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -size 10k -ls        #注意,size命令是模糊匹配,即查找10k表示大于9k小于等于10k的文件。

[root@node101.yinzhengjie.org.cn ~]# find -size -10k -ls        #和上面不同,"-10k"表示匹配小于10k的文件哟
dr-xr-x--- root root Dec : .
-rw------- root root Sep : ./.lesshst
-rw-r--r-- root root Dec ./.bash_profile
-rw-r--r-- root root Dec : ./d4.txt
-rw-r--r-- root root Dec ./.tcshrc
-rw-r--r-- root root Dec ./.cshrc
-rw------- root root Dec : ./.viminfo
-rw-r--r-- root root Dec ./.bash_logout
drwxr----- root root Dec : ./.pki
drwxr----- root root Dec : ./.pki/nssdb
-rw-r--r-- root root Dec ./.bashrc
-rw------- root root Dec : ./.mysql_history
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -size -10k -ls        #和上面不同,"-10k"表示查找小于10k的文件哟

[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : a.txt
-rw-r--r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -h
total 48K
-rw-r--r-- root root 10K Dec : a.txt
-rw-r--r-- root root .1K Dec : b.txt
-rw-r--r-- root root 11K Dec : c.txt
-rw-r--r-- root root .0K Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -size +10k -ls
-rw------- root root Dec : ./.bash_history
-rw-r--r-- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo >> a.txt              #添加一个"\n"字节
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -size +10k -ls          #表示查找大于10k的文件
-rw------- root root Dec : ./.bash_history
-rw-r--r-- root root Dec : ./a.txt
-rw-r--r-- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -size +10k -ls        #表示查找大于10k的文件

13>.根据时间戳查找

以"天"为单位:
  -atime(可以指定创建时间的天数范围)
    #: [#,#+)
      如10,表示[,),即查找大于10天小于第11天的文件
    +#: [#+,∞]
      如10,表示[,∞],即查找大于10天的文件            -#: [,#)
      如10,表示[,),即查找小于10天的文件
  -mtime(和atime一样,也可以指定修改天数范围)
  -ctime(和atime一样,也可以指定创建天数范围) 以"分钟"为单位(按照分钟和按照天数用法几乎一样,只不过单位时间不同而已,指定时间范围,如下图所示。)
  -amin
  -mmin
  -cmin
[root@node101.yinzhengjie.org.cn ~]# useradd jason
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find /etc/ -mmin - -ls      #表示查找1分钟之内修改的文件
drwxr-xr-x root root Dec : /etc/
---------- root root Dec : /etc/shadow
-rw-r--r-- root root Dec : /etc/passwd
-rw-r--r-- root root Dec : /etc/group
---------- root root Dec : /etc/gshadow
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date
Thu Dec :: EST
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -mmin -1 -ls      #表示查找1分钟之内修改的文件

 

14>.根据权限查找

-perm [/|-]MODE
  MODE:
    精确权限匹配
  /MODE:
    任何一类(u,g,o)对象的权限中只要能一位匹配即可,或关系,+ 从centos7开始淘汰
  -MODE:
    每一类对象都必须同时拥有指定权限,与关系 表示不关注

示例:
  find -perm 会匹配权限模式恰好是755的文件
  只要当任意人有写权限时,find -perm +222就会匹配
  只有当每个人都有写权限时,find -perm -222才会匹配
  只有当其它人(other)有写权限时,find -perm -002才会匹配
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : a.txt
-rw-r--r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chmod a.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm -ls        #在当前目录下查找权限是640的文件
-rw-r----- root root Dec : ./a.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r----- root root Dec : a.txt
-rw-r--r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm 640 -ls        #在当前目录下精确查找权限是640的文件

[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls        #权限640对应着"rw-r-----",即要求所有者必须拥有读写权限,所属组有权限,0表示不关心,即有没有权限无所谓。
-rw-r--r-- root root Dec ./.bash_profile
-rw-r--r-- root root Dec : ./d4.txt
-rw-r--r-- root root Dec ./.tcshrc
-rw-r--r-- root root Dec ./.cshrc
-rw-r--r-- root root Dec ./.bash_logout
-rw-r----- root root Dec : ./a.txt
drwxr----- root root Dec : ./.pki
drwxr----- root root Dec : ./.pki/nssdb
-rw-r--r-- root root Dec ./.bashrc
-rw-r--r-- root root Dec : ./b.txt
-rw-r--r-- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chmod g-r a.txt b.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls #再次匹配时发现匹配不到a.txt和b.txt文件啦,因为这两个文件的所属组权限不满足咱们咋着条件4啦。
-rw-r--r-- root root Dec ./.bash_profile
-rw-r--r-- root root Dec : ./d4.txt
-rw-r--r-- root root Dec ./.tcshrc
-rw-r--r-- root root Dec ./.cshrc
-rw-r--r-- root root Dec ./.bash_logout
drwxr----- root root Dec : ./.pki
drwxr----- root root Dec : ./.pki/nssdb
-rw-r--r-- root root Dec ./.bashrc
-rw-r--r-- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw----r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -640 -ls        #权限640对应着"rw-r-----",即要求所有者必须拥有读写权限,所属组有权限,0表示不关心,即有没有权限无所谓。

[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw----r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--r-- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chmod a+w a.txt c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-rw- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-rw-rw- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls          #这里强制要求所有者,所属组和其他人都必须有写入权限。
-rw--w-rw- root root Dec : ./a.txt
-rw-rw-rw- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls        #这里强制要求所有者,所属组和其他人都必须有写入权限。

[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-rw- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-rw-rw- root root Dec : c.txt
-rw-r--r-- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls         #表示查找所有者必须有rw权限,所属组必须有r权限,其他人必须有w权限。
-rw-rw-rw- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -642 -ls         #表示查找所有者必须有rw权限,所属组必须有r权限,其他人必须有w权限。

[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-rw-rw- root root Dec : c.txt
-rw-r--rw- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm / -ls          #022对应的权限为"----w--w-",表示查找所属组或者其他人有写入权限的文件,即2个条件满足一个即可。
-rw-r--rw- root root Dec : ./d4.txt
-rw--w-r-- root root Dec : ./a.txt
-rw-rw-rw- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm /022 -ls          #022对应的权限为"----w--w-",表示查找所属组或者其他人有写入权限的文件,即2个条件满足一个即可。

15>.处理动作

搜索到文件后咱们可以做相应的处理,find命令支持以下处理动作:
  print:
    默认的处理动作,显示至屏幕
  -ls:
    类似于对查找到的文件执行"ls -l"命令
  -delete:
    删除查找到的文件
  -fls file:
    查找到的所有文件的长格式信息保存至指定文件中
  -ok COMMAND {} \;
    对查找到的每个文件执行由COMMAND指定的命令,{}表示引用查找到的文件名称自身,"\;"表示命令执行结束标示符。ok表示对于每个文件执行命令之前,都会交互式要求用户确认。
  exec COMMAND {} \;
    对查找到的每个文件执行由COMMAND指定的命令,和上面到功能类似,只不过执行命令时并不会有交互式要求用户确认,虽然方便,但是我们应该注意安全使用。
  {}:
    用于引用查找到的文件名称自身
find传递查找到的文件至后面指定的命令时,查找到所有符合条件的文件一次性传递给后面的命令
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-rw-rw- root root Dec : c.txt
-rw-r--rw- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls        #将查找的文件以常列表的形式列举出来。
-rw-rw-rw- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls                        #将查找的文件以常列表的形式列举出来。

[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls
-rw-rw-rw- root root Dec : ./c.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-rw-rw- root root Dec : c.txt
-rw-r--rw- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -delete      #将查找到的文件直接删除掉
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--rw- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -222 -delete                      #将查找到的文件直接删除掉

[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--rw- root root Dec : d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls
-rw-r--rw- root root Dec : ./d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -fls /root/res.log          #将查找到的结果重定向到指定文件中。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat res.log
-rw-r--rw- root root Dec : ./d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls > /root/res2.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat res2.log
-rw-r--rw- root root Dec : ./d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -002 -fls /root/res.log                #将查找到的结果重定向到指定文件中。

[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--rw- root root Dec : d4.txt
-rw-r--r-- root root Dec : res2.log
-rw-r--r-- root root Dec : res.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ls
-rw-r--rw- root root Dec : ./d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -perm - -ok mv {} /tmp \;
< mv ... ./d4.txt > ? y
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
-rw-r--r-- root root Dec : res2.log
-rw-r--r-- root root Dec : res.log
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /tmp/d4.txt
-rw-r--rw- root root Dec : /tmp/d4.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -002 -ok mv {} /tmp \;                #将查找到的文件移动到"/tmp"目录下,只能移动文件不能移动目录。使用-ok语法必须使用"\;"表示命令结束,而且执行命令前还会有交互式信息呢。

[root@node101.yinzhengjie.org.cn ~]# ll
total
drwxr-xr-x root root Dec : apache
-rw--w-r-- root root Dec : a.txt
-rw----r-- root root Dec : b.txt
drwxr-xr-x root root Dec : nginx
-rw-r--r-- root root Dec : res2.log
-rw-r--r-- root root Dec : res.log
drwxr-xr-x root root Dec : tomcat
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -type f -exec chmod a=rwx {} \;               #在当前目录下查找所有到文件类型并授权为"rwx"
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
drwxr-xr-x root root Dec : apache
-rwxrwxrwx root root Dec : a.txt
-rwxrwxrwx root root Dec : b.txt
drwxr-xr-x root root Dec : nginx
-rwxrwxrwx root root Dec : res2.log
-rwxrwxrwx root root Dec : res.log
drwxr-xr-x root root Dec : tomcat
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -type f -exec chmod a=rwx {} \;               #在当前目录下查找所有到文件类型并授权为"rwx",和上面相比,不会有交互界面。

  如上图所示,首先看一下我的家目录/root下被标记的文件,其次,让我们用find这个命令去做一件事情,如下图所示。 

  学东西要学会举一反三,我要删除30天之前的文件怎么搞呢?先闭上眼睛想一想,然后看看你跟我的操作是一样的吗?如下图所示。

三.xargs参数传递

xargs的由来:
  由于很多命令不支持管道|来传递参数,而日常工作中有这个必要,所以就有了xargs命令。 xargs的功能:
  xargs用于产生某个命令的参数,xargs可以读入stdin的数据,并且以空格符或回车符将stdin的数据分隔成为arguments。
  有些命令不能接受过多参数,命令执行可能会失败,xargs可以解决。 注意:
  文件名或者是其他意义的名词内含有空格符的情况 

1>.xargs的默认处理方式

[root@node101.yinzhengjie.org.cn ~]# seq 

[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# seq | xargs                     #默认情况下,xargs可以读入stdin的数据,并且以空格符将数据分为多个arguments [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs                         #默认情况下,xargs可以读入stdin的数据,并且以空格符将数据分为多个arguments

[root@node101.yinzhengjie.org.cn ~]# seq 

[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# seq | xargs [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# seq | xargs echo [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs echo                      #和上面输出等效

2>.将上一个标准输出的参数作为在一个命令的参数传递

[root@node101.yinzhengjie.org.cn ~]# echo "/etc/fstab"
/etc/fstab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo "/etc/fstab" | xargs cat            #xargs可以将echo的标准输出传递给cat命令作为参数 #
# /etc/fstab
# Created by anaconda on Thu Sep ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
/dev/mapper/VolGroup-lv_root / ext4 defaults
UUID=4e7ecb93-20a7-4ced-bf95-91974fc0b66a /boot ext4 defaults
/dev/mapper/VolGroup-lv_home /home ext4 defaults
/dev/mapper/VolGroup-lv_swap swap swap defaults
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/fstab #
# /etc/fstab
# Created by anaconda on Thu Sep ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
/dev/mapper/VolGroup-lv_root / ext4 defaults
UUID=4e7ecb93-20a7-4ced-bf95-91974fc0b66a /boot ext4 defaults
/dev/mapper/VolGroup-lv_home /home ext4 defaults
/dev/mapper/VolGroup-lv_swap swap swap defaults
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# echo "/etc/fstab" | xargs cat                #xargs可以将echo的标准输出传递给cat命令作为参数

3>."-n"参数使用

[root@node101.yinzhengjie.org.cn ~]# seq 

[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# seq | xargs -n          [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# seq | xargs -n             #可以通过"-n"来指定每行显示的最大参数个数。 [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs -n 3                       #可以通过"-n"来指定每行显示的最大参数个数。

4>.删除使用find命令找到的参数

[root@node101.yinzhengjie.org.cn ~]# touch "user name.txt"
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# touch file{..}.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : file1.txt
-rw-r--r-- root root Dec : file2.txt
-rw-r--r-- root root Dec : file3.txt
-rw-r--r-- root root Dec : user name.txt
-rw-r--r-- root root Dec : user.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mkdir nginx tomcat httpd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : file1.txt
-rw-r--r-- root root Dec : file2.txt
-rw-r--r-- root root Dec : file3.txt
drwxr-xr-x root root Dec : httpd
drwxr-xr-x root root Dec : nginx
drwxr-xr-x root root Dec : tomcat
-rw-r--r-- root root Dec : user name.txt
-rw-r--r-- root root Dec : user.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -name "*.txt" -print0 | xargs - ls
./file1.txt ./file2.txt ./file3.txt ./user name.txt ./user.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# find -name "*.txt" -print0 | xargs - rm        #删除匹配查找到到文件,注意"-print0"表示不以默认空格符来切分文件,而是使用ASCII表到0来分隔开文件,通常要和xargs到"-0"配合使用。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
drwxr-xr-x root root Dec : httpd
drwxr-xr-x root root Dec : nginx
drwxr-xr-x root root Dec : tomcat
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -name "*.txt" -print0 | xargs -0 rm          #删除匹配查找到到文件,注意"-print0"表示不以默认空格符来切分文件,而是使用ASCII表到0来分隔开文件,通常要和xargs到"-0"(表示null)配合使用。

5>.批量创建和删除用户案例

[root@node101.yinzhengjie.org.cn ~]# echo user{..} | xargs -n
user1
user2
user3
user4
user5
user6
user7
user8
user9
user10
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo user{..} | xargs -n useradd             #可以使用该命令批量创建10个用户
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd
user1:x::::/home/user1:/bin/bash
user2:x::::/home/user2:/bin/bash
user3:x::::/home/user3:/bin/bash
user4:x::::/home/user4:/bin/bash
user5:x::::/home/user5:/bin/bash
user6:x::::/home/user6:/bin/bash
user7:x::::/home/user7:/bin/bash
user8:x::::/home/user8:/bin/bash
user9:x::::/home/user9:/bin/bash
user10:x::::/home/user10:/bin/bash
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# echo user{1..10} | xargs -n 1 useradd             #可以使用该命令批量创建10个用户

[root@node101.yinzhengjie.org.cn ~]# ll /home/
total
drwx------. root root Sep : lost+found
drwx------ user1 user1 Dec : user1
drwx------ user10 user10 Dec : user10
drwx------ user2 user2 Dec : user2
drwx------ user3 user3 Dec : user3
drwx------ user4 user4 Dec : user4
drwx------ user5 user5 Dec : user5
drwx------ user6 user6 Dec : user6
drwx------ user7 user7 Dec : user7
drwx------ user8 user8 Dec : user8
drwx------ user9 user9 Dec : user9
drwx------. yinzhengjie yinzhengjie Dec : yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd
user1:x::::/home/user1:/bin/bash
user2:x::::/home/user2:/bin/bash
user3:x::::/home/user3:/bin/bash
user4:x::::/home/user4:/bin/bash
user5:x::::/home/user5:/bin/bash
user6:x::::/home/user6:/bin/bash
user7:x::::/home/user7:/bin/bash
user8:x::::/home/user8:/bin/bash
user9:x::::/home/user9:/bin/bash
user10:x::::/home/user10:/bin/bash
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo user{..} | xargs -n userdel -r          #咱们也可以批量删除用户了
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /home/
total
drwx------. root root Sep : lost+found
drwx------. yinzhengjie yinzhengjie Dec : yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# echo user{1..10} | xargs -n 1 userdel -r          #咱们也可以批量删除用户了

[root@node101.yinzhengjie.org.cn ~]# cat user.txt
jason100
jason200
jason300
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n
jason100
jason200
jason300
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n useradd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep jason /etc/passwd
jason100:x::::/home/jason100:/bin/bash
jason200:x::::/home/jason200:/bin/bash
jason300:x::::/home/jason300:/bin/bash
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n userdel -r
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grep jason /etc/passwd
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n 1 useradd              #也可以读取文件文件内容并进行创建或删除用户

6>.查看xargs命令的帮助信息

[root@node101.yinzhengjie.org.cn ~]# xargs --help
Usage: xargs [OPTION]... COMMAND INITIAL-ARGS...
Run COMMAND with arguments INITIAL-ARGS and more arguments read from input. Mandatory arguments to long options are mandatory for short options too.
Non-mandatory arguments are indicated by [square brackets]
-, --null Items are separated by a null, not whitespace.
Disables quote and backslash processing
-a, --arg-file=FILE Read arguments from FILE, not standard input
-d, --delimiter=CHARACTER Input items are separated by CHARACTER, not by
blank space. Disables quote and backslash
processing
-E END If END occurs as a line of input, the rest of
the input is ignored.
-e [END], --eof[=END] Equivalent to -E END if END is specified.
Otherwise, there is no end-of-file string
--help Print a summary of the options to xargs.
-I R same as --replace=R (R must be specified)
-i,--replace=[R] Replace R in initial arguments with names
read from standard input. If R is
unspecified, assume {}
-L,-l, --max-lines=MAX-LINES Use at most MAX-LINES nonblank input lines per
command line
-l Use at most one nonblank input line per
command line
-n, --max-args=MAX-ARGS Use at most MAX-ARGS arguments per command
line
-P, --max-procs=MAX-PROCS Run up to max-procs processes at a time
-p, --interactive Prompt before running commands
--process-slot-var=VAR Set environment variable VAR in child
processes
-r, --no-run-if-empty If there are no arguments, run no command.
If this option is not given, COMMAND will be
run at least once.
-s, --max-chars=MAX-CHARS Limit commands to MAX-CHARS at most
--show-limits Show limits on command-line length.
-t, --verbose Print commands before executing them
--version Print the version number
-x, --exit Exit if the size (see -s) is exceeded Report bugs to <bug-findutils@gnu.org>.
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# xargs --help

Linux操作系统的文件查找工具locate和find命令常用参数介绍的更多相关文章

  1. linux 两个查找工具 locate,find详解

    linux 中有很多查找工具,今天主要讲解locate,find两个工具. 1.locate (1)查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 注意:如果这 ...

  2. linux 两个查找工具 locate,find

    linux 中有很多查找工具,今天主要讲解locate,find两个工具. 一.locate 1.性能介绍 查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 注意 ...

  3. linux文件查找工具——locate,find

    一文件查找介绍 文件的查找就是在文件系统上查找符合条件的文件. 文件查找的方式:locate, find非实时查找也就是基于数据库查找的locate,效率特别高. 实时查找:find 二locate ...

  4. linux下文件查找工具--find

    常用的文件查找命令有:which,locate,find 1.which命令 查找二进制数或二进制命令,由PATH给出 2.loacte 特点: 1.非实时,每天在系统上生成数据库,通过数据库查询 2 ...

  5. 【Linux相识相知】文件查找(locate/find)

    在用linux操作系统的时候,当我们忘记之前某个文件存储的位置,但是知道其文件名或者模糊的知道其文件名,我们都可以通过文件查找工具来查找,linux提供两种常用的查找工具,locate和find,在日 ...

  6. Linux文件查找工具之find “大宝剑”--转载

    原文地址:http://xinzong.blog.51cto.com/10018904/1749465 一.文件查找工具常用软件 locate: locate命令其实是find -name的另一种写法 ...

  7. linux命令: 两个查找工具 locate,find

    linux 中有很多查找工具,今天主要讲解locate,find两个工具. 1.locate (1)查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 注意:如果这 ...

  8. Linux查找工具locate和find

    linux 中有很多查找工具,今天主要讲解locate,find两个工具. 一.locate 1.性能介绍 非实时查找(数据库查找):locate 查询系统上预建的文件索引数据库 /var/lib/m ...

  9. Linux操作系统的文件链接

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++标题:Linux操作系统的文件链接内容:文件链接时间:2019年 ...

随机推荐

  1. 使用response将html拼接页面写到当前浏览器端完成自动提交功能

    /** * 准备中间页面所需参数 * add by linyan  2014-9-22 * @param url * @param params * @param charset * @return ...

  2. [LeetCode] 264. Ugly Number II 丑陋数 II

    Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...

  3. [LeetCode] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  4. Java之java简介

    Java最早有SUN公司(已被Oracle收购)的詹姆斯高斯林在上个世纪90年代初开发的一种编程语言,最初被命名为Oak,目标是针对小型家电设备的嵌入式应用,结果市场没啥反响.谁料到互联网的崛起,让O ...

  5. python:对list去重

    1.set()方法 numbers = [1,7,3,2,5,6,2,3,4,1,5] new_numbers = list(set(numbers)) print new_numbers 输出 [1 ...

  6. webpack 4.0改版问题

    4.0之后的打包方式: webpack --mode development src/index.js --output-filename app.js --output-path dist

  7. 七、spring生命周期之初始化和销毁方法

    一.通过@Bean指定初始化和销毁方法 在以往的xml中,我们是这样配置的 <bean id="exampleInitBean" class="examples.E ...

  8. 查看端口被哪个程序占用的DOS命令

    netstat -aon | findstr 80Proto Local Address Foreign Address State PID==== ============ ============ ...

  9. java静态代理和JDK动态代理

    静态代理 编译阶段就生产了对应的代理类 public interface IBussiness { void execute(); } public class BussinessImpl imple ...

  10. 《Redis 分布式锁》

    一:什么是分布式锁. -  通俗来说的话,就是在分布式架构的redis中,使用锁. 二:分布式锁的使用选择. - 当 Redis 的使用场景不多,而且也只是单个在用的时候,可以构建自己使用的 锁. - ...