My locate command was not returning any files located in my encrypted home directory. As it turns out this is not indexed by default. It makes sense not to do this, indexing the encrypted home directory and storing the index in non encrypted locations may not be the best of ideas. However, I do want to be able to find my files. This askubuntu thread came to my rescue. The crux of the idea is to make an extra database with just the files from your encrypted home directory. This extra database is also stored in your encrypted home directory.

Creating of the usual database is done with the updatedb command. The updatedb command can also be used to create a database of just a certain location (with the -U argument) and storing it wherever you want (with the -o argument). There are also some directories I do not want indexed, like libraries or compilers relating to my programming environments. For this, you have the -e argument.

I create a bash file in my ~/bin/ directory in which all the arguments are set as they should be. The file:


IGNORE_PATHS="$HOME/.rbenv $HOME/.npm $HOME/.nvm $HOME/.gem $HOME/.rustup $HOME/.cargo"

updatedb -l 0 -e "$IGNORE_PATHS" -o $HOME/.local/share/mlocate.db -U $HOME

Executing this file will create a database in $HOME/.local/share/mlocate.db. I have not done so yet, but you probably want to add execution of this .sh file to your crontab so it gets executed automatically.

Now locate needs to actually use this database as well. To do so, the LOCATE_PATH needs to be set to the path of the database. This database is then searched in addition to the usual database. The easiest way to do this is by adding the following to your .bashrc (or .zshrc, or whatever shell you fancy).

export LOCATE_PATH=$HOME/.local/share/mlocate.db