www国产亚洲精品久久小说,在线 | 一区二区三区四区,综合成人亚洲网友偷自拍,中文字幕人妻第一区,最近中文字幕mv

微思網(wǎng)絡(luò)
全國免費電話:400-881-4699
當(dāng)前位置:首頁>微思動態(tài) > >詳情
全國熱線電話 400-881-4699

在線留言

【Linux】find命令 – 根據(jù)路徑和條件搜索指定文件

發(fā)布作者:微思網(wǎng)絡(luò)   發(fā)布時間:2025-04-27   瀏覽量:0


find命令的概念

find命令的功能是根據(jù)給定的路徑和條件查找相關(guān)文件或目錄,其參數(shù)靈活方便,且支持正則表達式,結(jié)合管道符后能夠?qū)崿F(xiàn)更加復(fù)雜的功能,是Linux系統(tǒng)運維人員必須掌握的命令之一。
find命令通常進行的是從根目錄(/)開始的全盤搜索,有別于whereis、which、locate等有條件或部分文件的搜索。對于服務(wù)器負(fù)載較高的情況,建議不要在高峰時期使用find命令的模糊搜索,這會相對消耗較多的系統(tǒng)資源。

圖片點鏈接跳轉(zhuǎn) 查看相關(guān)內(nèi)容文章

【資料領(lǐng)取】200個Linux常用命令手冊

find命令7種用法,你不會不知道把??。?/a>

find命令詳解

【干貨】31個實用Linux find命令的案例


微思-紅帽官方授權(quán)培訓(xùn)機構(gòu)





語法
find 路徑 條件 文件名




常用參數(shù)



參考示例

全盤搜索系統(tǒng)中所有以.conf結(jié)尾的文件:


[root@linuxcool ~]# find / -name *.conf 
/run/tmpfiles.d/kmod.conf 
/etc/resolv.conf 
/etc/dnf/dnf.conf 
/etc/dnf/plugins/copr.conf 
/etc/dnf/plugins/debuginfo-install.conf 
/etc/dnf/plugins/product-id.conf 
/etc/dnf/plugins/subscription-manager.conf 
………………省略部分輸出信息………………


在/etc目錄中搜索所有大于1MB的文件:


[root@linuxcool ~]# find /etc -size +1M 
/etc/selinux/targeted/policy/policy.31 
/etc/udev/hwdb.bin


在/home目錄中搜索所有屬于指定用戶的文件:


[root@linuxcool ~]# find /home -user linuxprobe 
/home/linuxprobe 
/home/linuxprobe/.mozilla 
/home/linuxprobe/.mozilla/extensions 
/home/linuxprobe/.mozilla/plugins 
/home/linuxprobe/.bash_logout 
/home/linuxprobe/.bash_profile 
/home/linuxprobe/.bashrc

列出當(dāng)前工作目錄中的所有文件、目錄以及子文件信息:


[root@linuxcool ~]# find . 
. 
./.bash_logout 
./.bash_profile 
./.bashrc 
./.cshrc 
./.tcshrc 
./anaconda-ks.cfg 
………………省略部分輸出信息………………

在/var/log目錄下搜索所有指定后綴的文件:


[root@linuxcool ~]# find 
/var/log -name "*.log" 
/var/log/audit/audit.log 
/var/log/rhsm/rhsmcertd.log 
/var/log/rhsm/rhsm.log 
/var/log/sssd/sssd.log 
/var/log/sssd/sssd_implicit_files.log 
/var/log/sssd/sssd_nss.log 
/var/log/sssd/sssd_kcm.log 
/var/log/tuned/tuned.log 
/var/log/anaconda/anaconda.log 
/var/log/anaconda/X.log 
………………省略部分輸出信息………………

在/var/log目錄下搜索所有不是以.log結(jié)尾的文件:


[root@linuxcool ~]# find 
/var/log ! -name "*.log" 
/var/log /var/log/lastlog 
/var/log/README 
/var/log/private 
/var/log/wtmp 
/var/log/btmp 
/var/log/samba

搜索當(dāng)前工作目錄中所有近7天被修改過的文件:


[root@linuxcool ~]# find . -mtime +7 
./.bash_logout 
./.bash_profile 
./.bashrc 
./.cshrc 
./.tcshrc 
………………省略部分輸出信息………………

全盤搜索系統(tǒng)中所有類型為目錄,且權(quán)限為1777的目錄文件:


[root@linuxcool ~]# find / -type d -perm 1777 
/dev/mqueue 
/dev/shm 
/var/tmp 
/tmp 
………………省略部分輸出信息………………

全盤搜索系統(tǒng)中所有類型為普通文件,且可以執(zhí)行的文件信息:


[root@linuxcool ~]# find / -type f -perm /a=x 
/boot/vmlinuz-4.18.0-80.el8.x86_64 
/boot/vmlinuz-0-rescue-c8b04558503242459d908c6c22a2d481 
/etc/X11/xinit/xinitrc.d/50-systemd-user.sh 
/etc/X11/xinit/xinitrc.d/00-start-message-bus.sh 
/etc/X11/xinit/xinitrc.d/localuser.sh 
/etc/X11/xinit/Xclients 
/etc/X11/xinit/Xsession 
/etc/X11/xinit/xinitrc 
………………省略部分輸出信息………………


全盤搜索系統(tǒng)中所有后綴為.mp4的文件,并刪除所有查找到的文件:


[root@linuxcool ~]# find / -name "*.mp4" -exec rm -rf {} \;




END

1微思網(wǎng)絡(luò),始于2002年

專業(yè)IT認(rèn)證培訓(xùn)23年,面向全國招生!



點擊查看更多【培訓(xùn)課程目錄】

微思-主要課程有:

*網(wǎng)絡(luò)技術(shù):華為HCIA/ HCIP/HCIE;思科CCNA/CCNP/CCIE

*Linux技術(shù):紅帽 RHCE/RHCA

*K8S&容器:CKA/CKS

*數(shù)據(jù)庫:ORACLE OCP/ OCM ;MySQL ;達夢數(shù)據(jù)庫

*虛擬化:VMware VCP/VCAP

*安全認(rèn)證:CISP體系/CISSP/ CISA;CCSK;CISAW體系

*管理類:PMP 項目管理;軟考中/高項;ITIL體系;Togaf

其他課程如:ACP;Azure...



?
返回頂部