The command locate and find are used to search a file by their filename. But difference is that locate command is a background process and searches the file in database whereas, find command searches in filesystem. The locate command is much faster than find command.
If you are unable to find a file with locate command then it means that your database is out of date, and you can updte your database with the updatedb command.
Look at the above snapshot, command "locate sysctl.conf" has displayed all the locations of file 'sysctl.conf'.