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:0.26-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================= Installing: mlocate x86_64 0.26-8.el7 base 113 k Transaction Summary ================================================================================================================================= Install 1 Package Total download size: 113 k Installed size: 379 k Downloading packages: mlocate-0.26-8.el7.x86_64.rpm | 113 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mlocate-0.26-8.el7.x86_64 1/1 Verifying : mlocate-0.26-8.el7.x86_64 1/1 Installed: mlocate.x86_64 0:0.26-8.el7 Complete! [root@node101.yinzhengjie.org.cn ~]#
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----- 1 root slocate 2483967 Dec 12 09:15 /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 0 -rw-r--r-- 1 root root 0 Dec 12 09:21 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/100/denyhosts /etc/selinux/targeted/active/modules/100/denyhosts/cil /etc/selinux/targeted/active/modules/100/denyhosts/hll /etc/selinux/targeted/active/modules/100/denyhosts/lang_ext /usr/lib64/security/pam_rhosts.so /usr/share/ghostscript /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /usr/share/doc/pam-1.1.8/html/sag-pam_rhosts.html /usr/share/doc/pam-1.1.8/txts/README.pam_rhosts /usr/share/ghostscript/conf.d /usr/share/man/man5/hosts.allow.5.gz /usr/share/man/man5/hosts.deny.5.gz /usr/share/man/man5/hosts_access.5.gz /usr/share/man/man5/hosts_options.5.gz /usr/share/man/man8/pam_rhosts.8.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/7/timedhosts /var/cache/yum/x86_64/7/timedhosts.txt /var/www/html/phpMyAdmin/examples/config.manyhosts.inc.php [root@node101.yinzhengjie.org.cn ~]#
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/100/denyhosts /etc/selinux/targeted/active/modules/100/denyhosts/cil /etc/selinux/targeted/active/modules/100/denyhosts/hll /etc/selinux/targeted/active/modules/100/denyhosts/lang_ext /usr/lib64/security/pam_rhosts.so /usr/share/ghostscript /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /usr/share/doc/pam-1.1.8/html/sag-pam_rhosts.html /usr/share/doc/pam-1.1.8/txts/README.pam_rhosts /usr/share/ghostscript/conf.d /usr/share/man/man5/hosts.allow.5.gz /usr/share/man/man5/hosts.deny.5.gz /usr/share/man/man5/hosts_access.5.gz /usr/share/man/man5/hosts_options.5.gz /usr/share/man/man8/pam_rhosts.8.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/7/timedhosts /var/cache/yum/x86_64/7/timedhosts.txt /var/www/html/phpMyAdmin/examples/config.manyhosts.inc.php [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
5>."-n"選項案例

[root@node101.yinzhengjie.org.cn ~]# locate hosts /etc/hosts /etc/hosts.allow /etc/hosts.deny /etc/selinux/targeted/active/modules/100/denyhosts /etc/selinux/targeted/active/modules/100/denyhosts/cil /etc/selinux/targeted/active/modules/100/denyhosts/hll /etc/selinux/targeted/active/modules/100/denyhosts/lang_ext /usr/lib64/security/pam_rhosts.so /usr/share/ghostscript /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /usr/share/doc/pam-1.1.8/html/sag-pam_rhosts.html /usr/share/doc/pam-1.1.8/txts/README.pam_rhosts /usr/share/ghostscript/conf.d /usr/share/man/man5/hosts.allow.5.gz /usr/share/man/man5/hosts.deny.5.gz /usr/share/man/man5/hosts_access.5.gz /usr/share/man/man5/hosts_options.5.gz /usr/share/man/man8/pam_rhosts.8.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/7/timedhosts /var/cache/yum/x86_64/7/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 5 hosts #之列出前5個匹配到的文件名稱或路徑名稱 /etc/hosts /etc/hosts.allow /etc/hosts.deny /etc/selinux/targeted/active/modules/100/denyhosts /etc/selinux/targeted/active/modules/100/denyhosts/cil [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
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/00-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-1/session.conf /etc/dbus-1/system.conf /etc/dbus-1/system.d/FirewallD.conf /etc/dbus-1/system.d/com.redhat.tuned.conf /etc/dbus-1/system.d/nm-dispatcher.conf /etc/dbus-1/system.d/nm-ifcfg-rh.conf /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf /etc/dbus-1/system.d/org.freedesktop.hostname1.conf /etc/dbus-1/system.d/org.freedesktop.import1.conf /etc/dbus-1/system.d/org.freedesktop.locale1.conf /etc/dbus-1/system.d/org.freedesktop.login1.conf /etc/dbus-1/system.d/org.freedesktop.machine1.conf /etc/dbus-1/system.d/org.freedesktop.systemd1.conf /etc/dbus-1/system.d/org.freedesktop.timedate1.conf /etc/dbus-1/system.d/teamd.conf /etc/dbus-1/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/00-base.conf /etc/httpd/conf.modules.d/00-dav.conf /etc/httpd/conf.modules.d/00-lua.conf /etc/httpd/conf.modules.d/00-mpm.conf /etc/httpd/conf.modules.d/00-proxy.conf /etc/httpd/conf.modules.d/00-systemd.conf /etc/httpd/conf.modules.d/01-cgi.conf /etc/httpd/conf.modules.d/10-php.conf /etc/ld.so.conf.d/kernel-3.10.0-957.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/20-nproc.conf /etc/selinux/semanage.conf /etc/selinux/targeted/setrans.conf /etc/sysctl.d/99-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.9/Doc/docutils.conf /home/yinzhengjie/.pyenv/cache/Python-3.6.9/Doc/tools/pydoctheme/theme.conf /usr/lib/NetworkManager/conf.d/10-slaves-order.conf /usr/lib/dracut/dracut.conf.d/01-dist.conf /usr/lib/dracut/dracut.conf.d/01-microcode.conf /usr/lib/dracut/dracut.conf.d/02-rescue.conf /usr/lib/dracut/dracut.conf.d/50-nss-softokn.conf /usr/lib/dracut/dracut.conf.d/76-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/00-system.conf /usr/lib/sysctl.d/10-default-yama-scope.conf /usr/lib/sysctl.d/50-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/50-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-1/session.conf /usr/share/dbus-1/system.conf /usr/share/doc/NetworkManager/examples/server.conf /usr/share/doc/alsa-lib/modprobe-dist-oss.conf /usr/share/doc/dbus-1.10.24/examples/example-session-disable-stats.conf /usr/share/doc/dbus-1.10.24/examples/example-system-enable-stats.conf /usr/share/doc/glibc-common-2.17/gai.conf /usr/share/doc/gnupg2-2.0.22/examples/gpgconf.conf /usr/share/doc/httpd-2.4.6/httpd-dav.conf /usr/share/doc/httpd-2.4.6/httpd-default.conf /usr/share/doc/httpd-2.4.6/httpd-info.conf /usr/share/doc/httpd-2.4.6/httpd-languages.conf /usr/share/doc/httpd-2.4.6/httpd-manual.conf /usr/share/doc/httpd-2.4.6/httpd-mpm.conf /usr/share/doc/httpd-2.4.6/httpd-multilang-errordoc.conf /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /usr/share/doc/httpd-2.4.6/proxy-html.conf /usr/share/doc/krb5-libs-1.15.1/examples/kdc.conf /usr/share/doc/krb5-libs-1.15.1/examples/krb5.conf /usr/share/doc/python-configobj-4.7.2/docutils.conf /usr/share/doc/python-slip-0.4.0/dbus/example/org.fedoraproject.slip.example.mechanism.conf /usr/share/doc/python-slip-dbus-0.4.0/example/org.fedoraproject.slip.example.mechanism.conf /usr/share/doc/sudo-1.8.23/examples/pam.conf /usr/share/doc/sudo-1.8.23/examples/sudo.conf /usr/share/doc/sudo-1.8.23/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.0-957.el7.x86_64/include/config/auto.conf /usr/src/kernels/3.10.0-957.el7.x86_64/include/config/tristate.conf /var/lib/NetworkManager/NetworkManager-intern.conf [root@node101.yinzhengjie.org.cn ~]#
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 -0, --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 ~]#
二.實時查找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 ~]#
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 ~]#
3>.查找指定路徑下的所有文件

[root@node101.yinzhengjie.org.cn ~]# ll -R test/ test/: total 0 -rw-r--r-- 1 root root 0 Dec 12 10:08 a -rw-r--r-- 1 root root 0 Dec 12 10:08 f2.log -rw-r--r-- 1 root root 0 Dec 12 10:08 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 ~]#
4>.指定搜索層級

[root@node101.yinzhengjie.org.cn ~]# find / -maxdepth 1 #表示在根目錄開始查找文件,最大搜索目錄深度為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 /etc/pki/ -maxdepth 1 /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/ -mindepth 1 /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-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 /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 3 -maxdepth 3 /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 ~]#
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-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 /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/ #默認先顯示文件夾,后顯示文件 /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-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 /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 ~]#
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 [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-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 ~]# ll -i /etc/sysconfig/network-scripts/ifcfg-eth0 788769 -rw-r--r--. 1 root root 162 Sep 5 02:37 /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 4 -rw-r--r--. 2 root root 162 Sep 5 02:37 ifcf-eth0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find / -inum 788769 #基於inode節點編號查找文件 /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcf-eth0 [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find / -inum 64 -ls #列出查找到到文件 64 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 910 Sep 9 05:55 /home/yinzhengjie/.pyenv/versions/3.6.9/envs/jason/lib/python3.6/site-packages/notebook/static/components/MathJax/extensions/a11y/mathmaps/es/symbols/math_non_characters.js 64 0 --w------- 1 root root 4096 Dec 11 15:26 /sys/bus/memory/uevent 64 0 -rw-r--r-- 1 root root 0 Dec 11 15:25 /sys/kernel/debug/tracing/function_profile_enabled [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll -i /etc/sysconfig/network-scripts/ifcfg-eth0 788769 -rw-r--r--. 2 root root 162 Sep 5 02:37 /etc/sysconfig/network-scripts/ifcfg-eth0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll -i total 4 788769 -rw-r--r--. 2 root root 162 Sep 5 02:37 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/ -links 6 -ls #在"/etc"目錄下查看鏈接數為6的文件 786505 4 drwxr-xr-x 6 root root 4096 Dec 11 09:30 /etc/sysconfig 786977 4 drwxr-xr-x 6 root root 4096 Sep 5 01:49 /etc/lvm 786680 4 drwxr-xr-x 6 root root 4096 Mar 12 2019 /etc/pki/CA 786613 4 drwxr-xr-x 6 root root 4096 Sep 5 01:48 /etc/security 786553 4 drwxr-xr-x 6 root root 4096 Sep 5 01:49 /etc/yum [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -regex ".*\.sh$" #在"/etc"目錄下查看以".sh"結尾的文件名稱,注意,find和locate不同,find的正則表達式要求咱們匹配文件的全路徑。 /etc/kernel/postinst.d/51-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 ~]#
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的文件 396207 4 drwxrwxr-x 4 yinzhengjie yinzhengjie 4096 Sep 9 06:05 /home/yinzhengjie/devops/ 396389 4 drwxrwxr-x 2 yinzhengjie yinzhengjie 4096 Sep 9 06:06 /home/yinzhengjie/devops/op 396390 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 9 Sep 9 06:06 /home/yinzhengjie/devops/op/.python-version 396209 4 drwxrwxr-x 2 yinzhengjie yinzhengjie 4096 Sep 9 05:55 /home/yinzhengjie/devops/cmdb 396206 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 6 Sep 9 05:55 /home/yinzhengjie/devops/cmdb/.python-version [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[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{1..3}.txt [centos@node101.yinzhengjie.org.cn ~]$ [centos@node101.yinzhengjie.org.cn ~]$ ll /tmp/ total 0 -rw-rw-r-- 1 centos centos 0 Dec 12 11:07 a1.txt -rw-rw-r-- 1 centos centos 0 Dec 12 11:07 a2.txt -rw-rw-r-- 1 centos centos 0 Dec 12 11:07 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 0 -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 a1.txt -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 a2.txt -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 a3.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find /tmp/ -nouser -ls #查看沒有屬主的文件 1179657 0 -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 /tmp/a1.txt 1179661 0 -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 /tmp/a2.txt 1179663 0 -rw-rw-r-- 1 1001 1001 0 Dec 12 11:07 /tmp/a3.txt [root@node101.yinzhengjie.org.cn ~]#

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

[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 ~]#
10>.組合查找

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user root #在"/etc"目錄下查找以".sh"結尾,而且用戶名是root的文件,這是邏輯與的關系。 /etc/kernel/postinst.d/51-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/51-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 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find /etc/ -name "*.sh" -a -user root | wc -l 10 [root@node101.yinzhengjie.org.cn ~]#

[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/51-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 ~]# ll /etc/pki/ca-trust/ total 16 -rw-r--r--. 1 root root 980 May 14 2018 ca-legacy.conf drwxr-xr-x. 5 root root 4096 Sep 5 01:48 extracted -rw-r--r--. 1 root root 166 May 14 2018 README drwxr-xr-x. 4 root root 4096 Sep 5 01:48 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 ~]#
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 9 04:52:36 EDT 2019 on pts/0 [yinzhengjie@node101.yinzhengjie.org.cn ~]$ [yinzhengjie@node101.yinzhengjie.org.cn ~]$ touch a{1..3}.txt [yinzhengjie@node101.yinzhengjie.org.cn ~]$ [yinzhengjie@node101.yinzhengjie.org.cn ~]$ [yinzhengjie@node101.yinzhengjie.org.cn ~]$ touch /etc/yinzhengjie/httpd{1..3}.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 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 19 Dec 12 19:50 domain.info -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 httpd1.conf -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 httpd2.conf -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 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-1/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 786771 4 drwx------ 2 polkitd root 4096 Sep 5 01:49 /etc/polkit-1/rules.d 788795 4 drwxr-xr-x 2 yinzhengjie root 4096 Dec 12 19:50 /etc/yinzhengjie 788827 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd3.conf 788824 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd1.conf 788825 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd2.conf 788828 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 19 Dec 12 19:50 /etc/yinzhengjie/domain.info [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find /etc/ -not \( -user root -o -user apache \) | wc -l 6 [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user root -a -not -user apache #在"/etc"目錄下遞歸查找屬主不是root而且屬主也不是apache的所有文件 /etc/polkit-1/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 6 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find /etc/ -not -user root -a -not -user apache -ls 786771 4 drwx------ 2 polkitd root 4096 Sep 5 01:49 /etc/polkit-1/rules.d 788795 4 drwxr-xr-x 2 yinzhengjie root 4096 Dec 12 19:50 /etc/yinzhengjie 788827 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd3.conf 788824 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd1.conf 788825 0 -rw-rw-r-- 1 yinzhengjie yinzhengjie 0 Dec 12 19:49 /etc/yinzhengjie/httpd2.conf 788828 4 -rw-rw-r-- 1 yinzhengjie yinzhengjie 19 Dec 12 19:50 /etc/yinzhengjie/domain.info [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
12>.根據文件大小來查找
-size [+|-]#UNIT 常用單位:
k, M, G,c(byte)
#UNIT: (#-1, #] 如:6k 表示(5k,6k],即查找大於5k小於等於6k的文件。
-#UNIT:[0,#-1] 如:-6k 表示[0,6k],即查找小於6k的文件。
+#UNIT:(#,∞) 如:+6k 表示(6k,∞),即查找大於6k的文件。

[root@node101.yinzhengjie.org.cn ~]# dd if=/dev/zero of=a.txt bs=1K count=10 10+0 records in 10+0 records out bytes (10 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=9 9+0 records in 9+0 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=11 11+0 records in 11+0 records out bytes (11 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=9 9+0 records in 9+0 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 48 -rw-r--r-- 1 root root 10240 Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9216 Dec 12 20:23 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll -h total 48K -rw-r--r-- 1 root root 10K Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9.0K Dec 12 20:23 b.txt -rw-r--r-- 1 root root 11K Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9.0K Dec 12 20:24 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 48 -rw-r--r-- 1 root root 10240 Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll -h total 48K -rw-r--r-- 1 root root 10K Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9.1K Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11K Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9.0K Dec 12 20:24 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的文件。 12 -rw-r--r-- 1 root root 10240 Dec 12 20:23 ./a.txt 12 -rw-r--r-- 1 root root 9217 Dec 12 20:25 ./b.txt [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -size -10k -ls #和上面不同,"-10k"表示匹配小於10k的文件喲 4 dr-xr-x--- 3 root root 4096 Dec 12 20:24 . 4 -rw------- 1 root root 48 Sep 5 03:31 ./.lesshst 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bash_profile 12 -rw-r--r-- 1 root root 9216 Dec 12 20:24 ./d4.txt 4 -rw-r--r-- 1 root root 129 Dec 28 2013 ./.tcshrc 4 -rw-r--r-- 1 root root 100 Dec 28 2013 ./.cshrc 8 -rw------- 1 root root 6442 Dec 11 17:32 ./.viminfo 4 -rw-r--r-- 1 root root 18 Dec 28 2013 ./.bash_logout 4 drwxr----- 3 root root 4096 Dec 11 16:20 ./.pki 4 drwxr----- 2 root root 4096 Dec 11 16:20 ./.pki/nssdb 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bashrc 4 -rw------- 1 root root 1191 Dec 12 09:08 ./.mysql_history [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw-r--r-- 1 root root 10240 Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll -h total 48K -rw-r--r-- 1 root root 10K Dec 12 20:23 a.txt -rw-r--r-- 1 root root 9.1K Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11K Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9.0K Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -size +10k -ls 24 -rw------- 1 root root 21053 Dec 12 20:09 ./.bash_history 12 -rw-r--r-- 1 root root 11264 Dec 12 20:23 ./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的文件 24 -rw------- 1 root root 21053 Dec 12 20:09 ./.bash_history 12 -rw-r--r-- 1 root root 10241 Dec 12 20:35 ./a.txt 12 -rw-r--r-- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
13>.根據時間戳查找
以"天"為單位: -atime(可以指定創建時間的天數范圍) #: [#,#+1) 如10,表示[10,11),即查找大於10天小於第11天的文件 +#: [#+1,∞] 如10,表示[11,∞],即查找大於10天的文件 -#: [0,#) 如10,表示[0,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 -1 -ls #表示查找1分鍾之內修改的文件 786433 4 drwxr-xr-x 77 root root 4096 Dec 12 20:51 /etc/ 788826 4 ---------- 1 root root 603 Dec 12 20:51 /etc/shadow 788833 4 -rw-r--r-- 1 root root 1051 Dec 12 20:51 /etc/passwd 788779 4 -rw-r--r-- 1 root root 544 Dec 12 20:51 /etc/group 788823 4 ---------- 1 root root 438 Dec 12 20:51 /etc/gshadow [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# date Thu Dec 12 20:52:07 EST 2019 [root@node101.yinzhengjie.org.cn ~]#

14>.根據權限查找
-perm [/|-]MODE MODE:
精確權限匹配 /MODE:
任何一類(u,g,o)對象的權限中只要能一位匹配即可,或關系,+ 從centos7開始淘汰 -MODE:
每一類對象都必須同時擁有指定權限,與關系 0 表示不關注
示例:
find -perm 755 會匹配權限模式恰好是755的文件 只要當任意人有寫權限時,find -perm +222就會匹配 只有當每個人都有寫權限時,find -perm -222才會匹配 只有當其它人(other)有寫權限時,find -perm -002才會匹配

[root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw-r--r-- 1 root root 10241 Dec 12 20:35 a.txt -rw-r--r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# chmod 640 a.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm 640 -ls #在當前目錄下查找權限是640的文件 1048583 12 -rw-r----- 1 root root 10241 Dec 12 20:35 ./a.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw-r----- 1 root root 10241 Dec 12 20:35 a.txt -rw-r--r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -640 -ls #權限640對應着"rw-r-----",即要求所有者必須擁有讀寫權限,所屬組有權限,0表示不關心,即有沒有權限無所謂。 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bash_profile 12 -rw-r--r-- 1 root root 9216 Dec 12 20:24 ./d4.txt 4 -rw-r--r-- 1 root root 129 Dec 28 2013 ./.tcshrc 4 -rw-r--r-- 1 root root 100 Dec 28 2013 ./.cshrc 4 -rw-r--r-- 1 root root 18 Dec 28 2013 ./.bash_logout 12 -rw-r----- 1 root root 10241 Dec 12 20:35 ./a.txt 4 drwxr----- 3 root root 4096 Dec 11 16:20 ./.pki 4 drwxr----- 2 root root 4096 Dec 11 16:20 ./.pki/nssdb 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bashrc 12 -rw-r--r-- 1 root root 9217 Dec 12 20:25 ./b.txt 12 -rw-r--r-- 1 root root 11264 Dec 12 20:23 ./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 -640 -ls #再次匹配時發現匹配不到a.txt和b.txt文件啦,因為這兩個文件的所屬組權限不滿足咱們咋着條件4啦。 1048579 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bash_profile 1056283 12 -rw-r--r-- 1 root root 9216 Dec 12 20:24 ./d4.txt 1048582 4 -rw-r--r-- 1 root root 129 Dec 28 2013 ./.tcshrc 1048581 4 -rw-r--r-- 1 root root 100 Dec 28 2013 ./.cshrc 1048578 4 -rw-r--r-- 1 root root 18 Dec 28 2013 ./.bash_logout 1049804 4 drwxr----- 3 root root 4096 Dec 11 16:20 ./.pki 1049806 4 drwxr----- 2 root root 4096 Dec 11 16:20 ./.pki/nssdb 1048580 4 -rw-r--r-- 1 root root 176 Dec 28 2013 ./.bashrc 1048588 12 -rw-r--r-- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw----r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw----r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 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 48 -rw--w-rw- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-rw-rw- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls #這里強制要求所有者,所屬組和其他人都必須有寫入權限。 1048583 12 -rw--w-rw- 1 root root 10241 Dec 12 20:35 ./a.txt 1048588 12 -rw-rw-rw- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw--w-rw- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-rw-rw- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--r-- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -642 -ls #表示查找所有者必須有rw權限,所屬組必須有r權限,其他人必須有w權限。 1048588 12 -rw-rw-rw- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-rw-rw- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm /022 -ls #022對應的權限為"----w--w-",表示查找所屬組或者其他人有寫入權限的文件,即2個條件滿足一個即可。 1056283 12 -rw-r--rw- 1 root root 9216 Dec 12 20:24 ./d4.txt 1048583 12 -rw--w-r-- 1 root root 10241 Dec 12 20:35 ./a.txt 1048588 12 -rw-rw-rw- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
15>.處理動作
搜索到文件后咱們可以做相應的處理,find命令支持以下處理動作: print:
默認的處理動作,顯示至屏幕 -ls:
類似於對查找到的文件執行"ls -l"命令 -delete:
刪除查找到的文件 -fls file:
查找到的所有文件的長格式信息保存至指定文件中 -ok COMMAND {} \;
對查找到的每個文件執行由COMMAND指定的命令,{}表示引用查找到的文件名稱自身,"\;"表示命令執行結束標示符。ok表示對於每個文件執行命令之前,都會交互式要求用戶確認。 exec COMMAND {} \;
對查找到的每個文件執行由COMMAND指定的命令,和上面到功能類似,只不過執行命令時並不會有交互式要求用戶確認,雖然方便,但是我們應該注意安全使用。 {}:
用於引用查找到的文件名稱自身
find傳遞查找到的文件至后面指定的命令時,查找到所有符合條件的文件一次性傳遞給后面的命令

[root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-rw-rw- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls #將查找的文件以常列表的形式列舉出來。 1048588 12 -rw-rw-rw- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# find -perm -222 -ls 1048588 12 -rw-rw-rw- 1 root root 11264 Dec 12 20:23 ./c.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 48 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-rw-rw- 1 root root 11264 Dec 12 20:23 c.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -222 -delete #將查找到的文件直接刪除掉 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 36 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 36 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -002 -ls 1056283 12 -rw-r--rw- 1 root root 9216 Dec 12 20:24 ./d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -002 -fls /root/res.log #將查找到的結果重定向到指定文件中。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat res.log 1056283 12 -rw-r--rw- 1 root root 9216 Dec 12 20:24 ./d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -002 -ls > /root/res2.log [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat res2.log 1056283 12 -rw-r--rw- 1 root root 9216 Dec 12 20:24 ./d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 44 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 d4.txt -rw-r--r-- 1 root root 77 Dec 12 21:39 res2.log -rw-r--r-- 1 root root 77 Dec 12 21:38 res.log [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -002 -ls 1056283 12 -rw-r--rw- 1 root root 9216 Dec 12 20:24 ./d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -perm -002 -ok mv {} /tmp \; < mv ... ./d4.txt > ? y [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 32 -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt -rw-r--r-- 1 root root 77 Dec 12 21:39 res2.log -rw-r--r-- 1 root root 77 Dec 12 21:38 res.log [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /tmp/d4.txt -rw-r--rw- 1 root root 9216 Dec 12 20:24 /tmp/d4.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll total 32 drwxr-xr-x 2 root root 4096 Dec 12 21:51 apache -rw--w-r-- 1 root root 10241 Dec 12 20:35 a.txt -rw----r-- 1 root root 9217 Dec 12 20:25 b.txt drwxr-xr-x 2 root root 4096 Dec 12 21:51 nginx -rw-r--r-- 1 root root 77 Dec 12 21:39 res2.log -rw-r--r-- 1 root root 77 Dec 12 21:38 res.log drwxr-xr-x 2 root root 4096 Dec 12 21:51 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 44 drwxr-xr-x 2 root root 4096 Dec 12 21:51 apache -rwxrwxrwx 1 root root 10241 Dec 12 20:35 a.txt -rwxrwxrwx 1 root root 9217 Dec 12 20:25 b.txt drwxr-xr-x 2 root root 4096 Dec 12 21:51 nginx -rwxrwxrwx 1 root root 77 Dec 12 21:39 res2.log -rwxrwxrwx 1 root root 77 Dec 12 21:38 res.log drwxr-xr-x 2 root root 4096 Dec 12 21:51 tomcat [root@node101.yinzhengjie.org.cn ~]#
如上圖所示,首先看一下我的家目錄/root下被標記的文件,其次,讓我們用find這個命令去做一件事情,如下圖所示。
學東西要學會舉一反三,我要刪除30天之前的文件怎么搞呢?先閉上眼睛想一想,然后看看你跟我的操作是一樣的嗎?如下圖所示。
三.xargs參數傳遞
xargs的由來: 由於很多命令不支持管道|來傳遞參數,而日常工作中有這個必要,所以就有了xargs命令。 xargs的功能: xargs用於產生某個命令的參數,xargs可以讀入stdin的數據,並且以空格符或回車符將stdin的數據分隔成為arguments。 有些命令不能接受過多參數,命令執行可能會失敗,xargs可以解決。 注意: 文件名或者是其他意義的名詞內含有空格符的情況
1>.xargs的默認處理方式

[root@node101.yinzhengjie.org.cn ~]# seq 10 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs #默認情況下,xargs可以讀入stdin的數據,並且以空格符將數據分為多個arguments 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# seq 10 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs echo 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
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 5 01:48:13 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1 UUID=4e7ecb93-20a7-4ced-bf95-91974fc0b66a /boot ext4 defaults 1 2 /dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2 /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0 [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 5 01:48:13 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1 UUID=4e7ecb93-20a7-4ced-bf95-91974fc0b66a /boot ext4 defaults 1 2 /dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2 /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
3>."-n"參數使用

[root@node101.yinzhengjie.org.cn ~]# seq 10 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs -n 2 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# seq 10 | xargs -n 3 #可以通過"-n"來指定每行顯示的最大參數個數。 1 2 3 4 5 6 7 8 9 10 [root@node101.yinzhengjie.org.cn ~]#
4>.刪除使用find命令找到的參數

[root@node101.yinzhengjie.org.cn ~]# touch "user name.txt" [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# touch file{1..3}.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 0 Dec 13 17:24 file1.txt -rw-r--r-- 1 root root 0 Dec 13 17:24 file2.txt -rw-r--r-- 1 root root 0 Dec 13 17:24 file3.txt -rw-r--r-- 1 root root 0 Dec 13 17:24 user name.txt -rw-r--r-- 1 root root 27 Dec 13 17:12 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 16 -rw-r--r-- 1 root root 0 Dec 13 17:24 file1.txt -rw-r--r-- 1 root root 0 Dec 13 17:24 file2.txt -rw-r--r-- 1 root root 0 Dec 13 17:24 file3.txt drwxr-xr-x 2 root root 4096 Dec 13 17:25 httpd drwxr-xr-x 2 root root 4096 Dec 13 17:25 nginx drwxr-xr-x 2 root root 4096 Dec 13 17:25 tomcat -rw-r--r-- 1 root root 0 Dec 13 17:24 user name.txt -rw-r--r-- 1 root root 27 Dec 13 17:12 user.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# find -name "*.txt" -print0 | xargs -0 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 -0 rm #刪除匹配查找到到文件,注意"-print0"表示不以默認空格符來切分文件,而是使用ASCII表到0來分隔開文件,通常要和xargs到"-0"配合使用。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 12 drwxr-xr-x 2 root root 4096 Dec 13 17:25 httpd drwxr-xr-x 2 root root 4096 Dec 13 17:25 nginx drwxr-xr-x 2 root root 4096 Dec 13 17:25 tomcat [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
5>.批量創建和刪除用戶案例

[root@node101.yinzhengjie.org.cn ~]# echo user{1..10} | xargs -n 1 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{1..10} | xargs -n 1 useradd #可以使用該命令批量創建10個用戶 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd user1:x:1001:1001::/home/user1:/bin/bash user2:x:1002:1002::/home/user2:/bin/bash user3:x:1003:1003::/home/user3:/bin/bash user4:x:1004:1004::/home/user4:/bin/bash user5:x:1005:1005::/home/user5:/bin/bash user6:x:1006:1006::/home/user6:/bin/bash user7:x:1007:1007::/home/user7:/bin/bash user8:x:1008:1008::/home/user8:/bin/bash user9:x:1009:1009::/home/user9:/bin/bash user10:x:1010:1010::/home/user10:/bin/bash [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# ll /home/ total 60 drwx------. 2 root root 16384 Sep 5 01:48 lost+found drwx------ 2 user1 user1 4096 Dec 13 17:07 user1 drwx------ 2 user10 user10 4096 Dec 13 17:07 user10 drwx------ 2 user2 user2 4096 Dec 13 17:07 user2 drwx------ 2 user3 user3 4096 Dec 13 17:07 user3 drwx------ 2 user4 user4 4096 Dec 13 17:07 user4 drwx------ 2 user5 user5 4096 Dec 13 17:07 user5 drwx------ 2 user6 user6 4096 Dec 13 17:07 user6 drwx------ 2 user7 user7 4096 Dec 13 17:07 user7 drwx------ 2 user8 user8 4096 Dec 13 17:07 user8 drwx------ 2 user9 user9 4096 Dec 13 17:07 user9 drwx------. 7 yinzhengjie yinzhengjie 4096 Dec 12 19:48 yinzhengjie [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep user /etc/passwd user1:x:1001:1001::/home/user1:/bin/bash user2:x:1002:1002::/home/user2:/bin/bash user3:x:1003:1003::/home/user3:/bin/bash user4:x:1004:1004::/home/user4:/bin/bash user5:x:1005:1005::/home/user5:/bin/bash user6:x:1006:1006::/home/user6:/bin/bash user7:x:1007:1007::/home/user7:/bin/bash user8:x:1008:1008::/home/user8:/bin/bash user9:x:1009:1009::/home/user9:/bin/bash user10:x:1010:1010::/home/user10:/bin/bash [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo user{1..10} | xargs -n 1 userdel -r #咱們也可以批量刪除用戶了 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /home/ total 20 drwx------. 2 root root 16384 Sep 5 01:48 lost+found drwx------. 7 yinzhengjie yinzhengjie 4096 Dec 12 19:48 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 ~]# cat user.txt jason100 jason200 jason300 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n 1 jason100 jason200 jason300 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n 1 useradd [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep jason /etc/passwd jason100:x:1001:1001::/home/jason100:/bin/bash jason200:x:1002:1002::/home/jason200:/bin/bash jason300:x:1003:1003::/home/jason300:/bin/bash [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat user.txt | xargs -n 1 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 ~]#
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] -0, --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 ~]#