zoukankan      html  css  js  c++  java
  • Linux使用locate命令定位文件

    全文节选翻译自:http://linux-blog.org/finding-files-with-locate/

    FIND命令

    非常多Linux用户喜欢使用find命令来查找文件。比如他们通常喜欢这样做:

    find / -name 'pattern'

    确实find的强大功能不只用来查找文件,它能用来定位更加细节的东西,比方你想在某个文件夹下找到一些赋予其拥有者和管理员可写的权限( if you wanted to find files which are writable by both their owner and their group)。能够这样做:

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

    又或者你想看看在你的下载文件夹下的过去24小时之内被改动过的文件,

    find /home/user/Downloads/ -mtime 0

    find命令的强大不只用于查找文件,其搜索磁盘的时候是须要时间的。那么有没有高速定位的方法呢?

    LOCATE命令

    在使用locate之前,你得确认系统是否安装了mlocate 包,如今大多数Linux发行版都集成了此包。

    假设没有安装。能够訪问mlocate主页(http://carolina.mff.cuni.cz/~trmac/blog/mlocate/)下载安装。下载成功安装后,你须要运行一条命令为你的文件系统索引。否则你就得等到程序哪天自己主动运行了。

    已root用户身份运行例如以下命令:

    updatedb &

    这条命令会后台更新你的mlocate数据库。这数据库包括了你的文件系统的索引(This updates the mlocate database that indexes your files and forks it to the background (the ‘&’ forks it to the background)。

    等这条命令运行完了。你能够轻松的使用locate命令:

    locate firefox | less

    这会高速地定位有关firefox的文件、文件夹等等。速度也比find快,由于它读取的是mlocate数据库里面的索引。




  • 相关阅读:
    NSURLSessionDataDelegate 文件下载
    NSURLConnection 大文件下载
    全屏滑动
    qq粒子效果
    iOS 技巧
    iOS 15 新特性适配
    iOS 字符串转json 字符串转数组
    iOS 微信分享显示未验证应用2
    iOS 微信分享显示未验证应用1
    iOS 隐藏系统音量提示框
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6911502.html
Copyright © 2011-2022 走看看