Sample Header Ad - 728x90

`plocate` couldn't find results in my home dir but `mlocate` could. How to search results in home dir?

4 votes
2 answers
892 views
Currently I'm trying to migrate from mlocate to plocate. I'm using mlocate in my script (note: locate is aliased to either mlocate or plocate depending which one I've installed). ## Successfully searched home directory with mlocate Below is the first 10 outputs after running locate home (locate is aliased to mlocate):
/home
/etc/apparmor.d/tunables/home
/etc/apparmor.d/tunables/home.d
/etc/apparmor.d/tunables/home.d/site.local
/etc/systemd/homed.conf
/home/username
/home/username/.bash_history
/home/username/.bash_profile
/home/username/.bashrc
/home/username/.cache
/home/username/.cargo
As you can see, I could successfully find files in my home directories with mlocate. ## Unsuccessfully searched home directory with plocate: However, after installing plocate, I get results from /etc/, /usr/ etc, and all I get is one /home: After running locate home (locate is aliased to plocate):
/home
/etc/apparmor.d/tunables/home
/etc/apparmor.d/tunables/home.d
/etc/apparmor.d/tunables/home.d/site.local
/etc/systemd/homed.conf
/usr/bin/addgnupghome
/usr/bin/homectl
As you can see, plocate couldn't find files and directories in my home directory. ## What I've tried ### 1. Comment from author of plocate This manjaro thread [How to use plocate?](https://forum.manjaro.org/t/how-to-use-plocate/82592) has the author of plocate commented as below: > First, check that the database has been updated recently. Most users will want to use plocate’s updatedb; plocate-build (which converts from mlocate’s database) is generally not what you want since plocate 1.1.0. [...] > > The other reason why a file isn’t shown, is typically permissions. Check if you can find the files as root (sudo plocate test); if you can, the problem is most likely that you don’t have access rights to the directory all the way down from the root. plocate should find anything that find / -name *test* does, but no more. I've run sudo updatedb. My home dir access right:
/ 
➜ ll
drwxr-xr-x - root 17 Jul  2022 home/
drwxr-xr-x - root 16 Apr 21:44 usr/

/home 
➜ ll
drwxr-xr-x - username 16 Apr 21:51 username/
It does seem that plocate couldn't access files and directories under my home dir, but it has the same access right as usr. I don't understand why plocate can see usr but not files and dir under home. #### 2. Results are different when running as sudo The results are different when I run plocate as sudo. Below is regular locate:
➜  locate ranger
/usr/bin/ranger
/usr/lib/python3.10/site-packages/ranger
/usr/lib/python3.10/site-packages/ranger_fm-1.9.3-py3.10.egg-info
/usr/lib/python3.10/site-packages/ranger/__init__.py
/usr/lib/python3.10/site-packages/ranger/__pycache__
Below run as sudo:
➜  sudo locate ranger
/root/.config/ranger
/root/.local/share/ranger
/root/.local/share/ranger/bookmarks
/root/.local/share/ranger/history
/root/.local/share/ranger/tagged
/usr/bin/ranger
/usr/lib/python3.10/site-packages/ranger
/usr/lib/python3.10/site-packages/ranger_fm-1.9.3-py3.10.egg-info
I can see results in my home directories (i.e., first 5 results). ## What I want I'd like to be able to search my home directory with plocate the way I can do so with mlocate. In other words, I expect results from home directory when using plocate:
$ locate home
/home
/etc/apparmor.d/tunables/home
/etc/apparmor.d/tunables/home.d
/etc/apparmor.d/tunables/home.d/site.local
/etc/systemd/homed.conf
/home/username
/home/username/.bash_history
/home/username/.bash_profile
/home/username/.bashrc
/home/username/.cache
/home/username/.cargo
Asked by kohane15 (254 rep)
Apr 16, 2023, 02:00 PM
Last activity: Jul 19, 2025, 05:56 PM