自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux使用locate命令定位文件

系統(tǒng) Linux
很多Linux用戶喜歡使用find命令來(lái)查找文件,例如他們通常喜歡這樣做:find / -name 'pattern'。確實(shí)find的強(qiáng)大功能不僅僅用來(lái)查找文件,它能用來(lái)定位更加細(xì)節(jié)的東西……

FIND命令

很多Linux用戶喜歡使用find命令來(lái)查找文件,例如他們通常喜歡這樣做:

find / -name 'pattern'

確實(shí)find的強(qiáng)大功能不僅僅用來(lái)查找文件,它能用來(lái)定位更加細(xì)節(jié)的東西,比如你想在某個(gè)目錄下找到一些賦予其擁有者和管理員可寫的權(quán)限( if you wanted to find files which are writable by both their owner and their group),可以這樣做:

find / -perm -444 -perm /222 ! -perm /111

又或者你想看看在你的下載目錄下的過(guò)去24小時(shí)之內(nèi)被修改過(guò)的文件,

find /home/user/Downloads/ -mtime 0

find命令的強(qiáng)大不僅僅用于查找文件,其搜索磁盤的時(shí)候是需要時(shí)間的。那么有沒(méi)有快速定位的方法呢?

LOCATE命令

在使用locate之前,你得確認(rèn)系統(tǒng)是否安裝了mlocate包,現(xiàn)在大多數(shù)Linux發(fā)行版都集成了此包。如果沒(méi)有安裝,可以訪問(wèn)mlocate主頁(yè)(http://carolina.mff.cuni.cz/~trmac/blog/mlocate/下載安裝。下載安裝成功后,你需要執(zhí)行一條命令為你的文件系統(tǒng)索引。否則你就得等到程序哪天自動(dòng)執(zhí)行了。

已root用戶身份執(zhí)行如下命令:

updatedb &

這條命令會(huì)后臺(tái)更新你的mlocate數(shù)據(jù)庫(kù),這數(shù)據(jù)庫(kù)包含了你的文件系統(tǒng)的索引(This updates the mlocate database that indexes your files and forks it to the background (the ‘&’ forks it to the background)。

等這條命令執(zhí)行完了,你可以輕松的使用locate命令:

locate firefox | less

這會(huì)快速地定位有關(guān)firefox的文件、目錄等等。速度也比f(wàn)ind快,因?yàn)樗x取的是mlocate數(shù)據(jù)庫(kù)里面的索引!

原文鏈接:http://blog.csdn.net/hanszang/article/details/37994671

責(zé)任編輯:牛小雨 來(lái)源: csdn
相關(guān)推薦

2022-10-08 08:04:47

FindLinuxLocate

2009-08-04 08:44:56

linux find命linux find查找文件命令

2021-12-22 10:25:13

locateLinuxplocate

2011-07-27 17:30:40

iPhone Locate 定位

2019-12-17 09:00:48

split分割Linux文件Linux

2021-09-10 10:35:25

Linuxstat命令文件系統(tǒng)

2020-09-22 07:29:14

Linux stat

2009-08-03 12:02:13

linux at命令linux at命令詳使用案例

2018-05-09 12:27:34

Linux命令尋找文件

2018-11-12 09:30:49

Linux命令文件管理器

2010-03-18 16:38:39

Linux命令

2018-04-28 09:12:42

Linux

2022-05-25 08:41:48

Linuxfd 命令文件

2022-08-17 12:35:26

Linux sed編輯器

2009-12-23 10:58:58

Linux創(chuàng)建文件命令

2009-12-23 10:58:58

Linux創(chuàng)建文件命令

2012-05-10 08:55:11

Linuxuniq

2009-10-19 17:10:37

Linux文件命令

2021-04-06 09:46:15

Linuxanacron命令系統(tǒng)運(yùn)維

2009-08-03 12:21:03

linux at命令linux at命令詳定時(shí)關(guān)機(jī)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)