Search code examples
linuxlocate

why "locate" doesn't return all existing files?


I wonder why locate doesn't file all .exe files on my system depsite being up to date:

ebra@him:~$ sudo updatedb
ebra@him:~$ locate *.exe
/home/ebra/a.exe
/home/ebra/Downloads/santa.exe
ebra@him:~$ 
ebra@him:~$ ls /usr/share/nmap/nselib/data/psexec/nmap_service.exe
/usr/share/nmap/nselib/data/psexec/nmap_service.exe
ebra@him:~$ 

updatedb.conf:

ebra@him:~$ which updatedb
/usr/bin/updatedb
ebra@him:~$ which locate
/usr/bin/locate
ebra@him:~$ type /usr/bin/updatedb
/usr/bin/updatedb is /usr/bin/updatedb
ebra@him:~$ type /usr/bin/locate
/usr/bin/locate is /usr/bin/locate
ebra@him:~$ 
ebra@him:~$ cat /etc/updatedb.conf 
PRUNE_BIND_MOUNTS="yes"
# PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /home/.ecryptfs /var/lib/schroot"
PRUNEFS="NFS afs autofs binfmt_misc ceph cgroup cgroup2 cifs coda configfs curlftpfs debugfs devfs devpts devtmpfs ecryptfs ftpfs fuse.ceph fuse.cryfs fuse.encfs fuse.glusterfs fuse.gvfsd-fuse fuse.mfs fuse.rozofs fuse.sshfs fusectl fusesmb hugetlbfs iso9660 lustre lustre_lite mfs mqueue ncpfs nfs nfs4 ocfs ocfs2 proc pstore rpc_pipefs securityfs shfs smbfs sysfs tmpfs tracefs udev udf usbfs"
ebra@him:~$ 

Solution

  • Since your current (home) directory has a file named a.exe , the shell is expanding *.exe, and you are effectively running the command

    $ locate a.exe

    Try it either without the asterisk or with an escaped asterisk

    $ locate \*.exe