how to find the package that provides a file in linux

to search for the package that provides /bin/ls:

rpm (redhat derivatives)

rpm -qf /bin/ls

apt (debian derivatives)

dpkg -S /bin/ls

slackware

remove the leading slash from the file path:

grep '^bin/ls$' /var/log/packages/*