Ubuntu `系统搜索`另一个驱动器

Ubuntu `系统搜索`另一个驱动器

与其他发行版相比,我喜欢 Ubuntu 的一点是它能够快速搜索

我一直在寻找everything(Windows 工具)有时是一个替代方案,而且目前看来这是最好的。

但是,这个 Ubuntusystem search只搜索安装了操作系统的本地驱动器。

它不会搜索其他物理驱动器。

这可能吗?

答案1

Ubuntu 为此使用本地数据库。定位数据库是其一个版本,其配置文件位于/etc/updatedb.conf

内容:

$ more  /etc/updatedb.conf
PRUNE_BIND_MOUNTS="yes"
# PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /media /home/.ecryptfs /var/lib/schroot"
PRUNEFS="NFS nfs nfs4 rpc_pipefs afs binfmt_misc proc smbfs autofs iso9660 
ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre tmpfs usbfs 
udf fuse.glusterfs fuse.sshfs curlftpfs ecryptfs fusesmb devtmpfs"

正如您所看到的,很多位置尚未添加到索引中。

这是使用 locatedb 时添加路径的方法示例:

updatedb --localpaths '/ /media/usbdrive/dir/Music /media/usbdrive/dir/Photos'

我不确定是否需要,但是

sudo updatedb

将通过扫描您的磁盘来重新创建数据库,以防更改不会触发它。

答案2

让您的其他驱动器和分区自动安装在您的/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p6 during installation
UUID=b40b3925-70ef-447f-923e-1b05467c00e7 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p2 during installation
UUID=D656-F2A8  /boot/efi       vfat    umask=0077      0       1
# Windows drives C, D & E
UUID=F2C2ACE4C2ACADF3 /mnt/e    ntfs-3g permissions,locale=en_US.utf8,x-gvfs-show   0       0
UUID=F03ED48E3ED44F6A /mnt/d    ntfs-3g permissions,locale=en_US.utf8               0       0
UUID=5CCC5867CC583E08 /mnt/c    ntfs-3g permissions,locale=en_US.utf8,x-gvfs-show   0       0
# Broken Ubuntu 16.04
UUID=f3f8e7bc-b337-4194-88b8-3a513f6be55b /mnt/old        ext4    x-gvfs-show       0       0
# Clone Ubuntu 18.04
UUID=8337e8c8-6461-44f2-b5fe-dfd5b6b05883 /mnt/clone      ext4    x-gvfs-show       0       0
# swap was on /dev/nvme0n1p9 during installation
UUID=b4512bc6-0ec8-4b17-9edd-88db0f031332 none            swap    sw                0       0

所有这些都将自动被索引以便快速搜索。例如:

$ time locate .bashrc
/etc/bash.bashrc
/etc/skel/.bashrc
/home/rick/.bashrc
/home/rick/.bashrc~
/home/rick/restore/.bashrc
/home/rick/restore/.bashrc~
/mnt/clone/etc/bash.bashrc
/mnt/clone/etc/skel/.bashrc
/mnt/clone/home/rick/.bashrc
/mnt/clone/home/rick/.bashrc~
/mnt/clone/home/rick/eyesome/.bashrc
/mnt/clone/home/rick/restore/.bashrc
/mnt/clone/home/rick/restore/.bashrc~
/mnt/clone/usr/share/base-files/dot.bashrc
/mnt/clone/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/mnt/clone/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
/mnt/e/.bashrc
/mnt/e/Temporary Work/.bashrc
/mnt/old/etc/bash.bashrc
/mnt/old/etc/skel/.bashrc
/mnt/old/home/rick/.bashrc
/mnt/old/home/rick/.bashrc~
/mnt/old/usr/share/base-files/dot.bashrc
/mnt/old/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/mnt/old/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
/usr/share/base-files/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc

real    0m0.868s
user    0m0.852s
sys     0m0.017s

甚至 Windows 文件也被编入索引:

$ time locate /cmd.exe
/mnt/c/Windows/SysWOW64/cmd.exe
/mnt/c/Windows/SysWOW64/en-US/cmd.exe.mui
/mnt/c/Windows/System32/cmd.exe
/mnt/c/Windows/System32/en-US/cmd.exe.mui
/mnt/c/Windows/WinSxS/amd64_microsoft-windows-c..andprompt.resources_31bf3856ad364e35_10.0.17134.1_en-us_65026a8ffb1498f6/cmd.exe.mui
/mnt/c/Windows/WinSxS/amd64_microsoft-windows-commandprompt_31bf3856ad364e35_10.0.17134.1_none_708d53148386ef59/cmd.exe
/mnt/c/Windows/WinSxS/wow64_microsoft-windows-c..andprompt.resources_31bf3856ad364e35_10.0.17134.1_en-us_6f5714e22f755af1/cmd.exe.mui
/mnt/c/Windows/WinSxS/wow64_microsoft-windows-commandprompt_31bf3856ad364e35_10.0.17134.1_none_7ae1fd66b7e7b154/cmd.exe
/mnt/d/Windows/SysWOW64/cmd.exe
/mnt/d/Windows/SysWOW64/en-US/cmd.exe.mui
/mnt/d/Windows/System32/cmd.exe
/mnt/d/Windows/System32/en-US/cmd.exe.mui
/mnt/d/Windows/WinSxS/amd64_microsoft-windows-c..andprompt.resources_31bf3856ad364e35_10.0.10586.0_en-us_0c0776913c41663d/cmd.exe.mui
/mnt/d/Windows/WinSxS/amd64_microsoft-windows-commandprompt_31bf3856ad364e35_10.0.10586.0_none_17925f15c4b3bca0/cmd.exe
/mnt/d/Windows/WinSxS/wow64_microsoft-windows-c..andprompt.resources_31bf3856ad364e35_10.0.10586.0_en-us_165c20e370a22838/cmd.exe.mui
/mnt/d/Windows/WinSxS/wow64_microsoft-windows-commandprompt_31bf3856ad364e35_10.0.10586.0_none_21e70967f9147e9b/cmd.exe

real    0m0.989s
user    0m0.980s
sys     0m0.008s

我添加了该time命令,以便您可以看到它花费的时间不到一秒钟。要计算所有索引文件的数量,请使用:

$ time locate * | wc -l
625125

real    0m39.088s
user    0m38.644s
sys     0m0.423s

39列出 625,125 个文件名并对其进行计数需要几秒钟。

相关内容