Sobes.tech
Senior

Where are binary files located in Linux? How to find a compiled binary placed in /opt?

sobes.tech AI

Answer from AI

In Linux, binary files are usually located in directories like /bin, /usr/bin, /usr/local/bin, and similar, which are included in the environment variable PATH.

If you have a compiled binary placed in /opt, you can find it in several ways:

  1. Use the find command:
find /opt -type f -executable -name 'binary_name'

This will find the executable file with the specified name.

  1. If the filename is unknown, you can search for all executable files:
find /opt -type f -executable
  1. You can use ls to view the contents:
ls -l /opt
  1. If the binary is run through a symbolic link, you can use which or whereis, but they only search in PATH.

Therefore, the best way to find a binary in /opt is to use find with the -executable option.