I'm setting up prometheus in a web server, and I noticed that each exporter is its own program that must be added to a directory in $PATH.

My question is, is there any advantage to making a specialized directory for these (for example, "/usr/exporters/bin", to make up some example) and put all exporter programs in there, and add that file to the $PATH? Or is it best to just push the programs to the default directory for housing binaries?

3 Answers 3


The only benefit is having fewer directories in $PATH, therefore, fewer directories to search when looking for an executable, but:

  • This event (searching all the directories in $PATH) is rare. $PATH entries (the executables) are kept in a hash table within bash, which is updated at startup or via rehash. No need to search $PATH every time.

  • This event isn't expensive. All the information needed (file exists and permissions allow eXecution) can be gathered from the file's directory entry - no need to access each file. Just read the directory.

The reason for NOT moving the executables to a common other directory include:

  • You'll have a non-standard environment. When you ask for help, extra effort will be needed to explain this. Problems caused specifically by the non-standard environment will be very difficult to solve.

  • You'll have a non-standard environment. When updated versions are released, you environment won't match what the update expects.

  • You'll have a non-standard environment. You'll have to remember and do the non-standard environment updates this week, next week, the week after that, ... forever.

It's Monkey Motion for no benefit.

  • 1
    /use/local/bin is reserved for this use on most distributions. So it wouldn't be non-standard. Also one downside is each user on the system needs the PATH to be updated. That can be tricky where some users may have customised their own PATH. Jun 14, 2021 at 21:01
  • I customize my $PATH, but I treat it as a pre-existing value to be carefully modified. Never have a "PATH= expression that fails to include $PATH on the right hand side. I use Stephen Collyer's bash_path_funcs, described in Linux Journal way back in 2000: linuxjournal.com/article/3645 linuxjournal.com/article/3768 linuxjournal.com/article/3935 The addpath function adds an entry to a path only if it is not there in the first place. delpath -n deletes all non-existent directories from a path. You can get the `pathfunc.t
    – waltinator
    Jun 15, 2021 at 0:53
  • Part 2: You can get the pathfunc.tgz file from web.archive.org/web/20061210054813/http://…
    – waltinator
    Jun 15, 2021 at 0:54
  • 1
    You missed the point that /use/local/bin is the standard place to put custom binaries. and I'm not talking about modifying your own path. That's trivial. You have no control over what other users do in their .profile. However use/local/bin is such a common standard it's less likely to be dropped. Jun 15, 2021 at 7:04

Keeping binaries in the directories with matching libraries is quite common. The use case is version control. Say when you have several versions of python (2.7, 2.7, 3...) installed and need them all but want to define a standard.

Typically this uses the alternatives suite and softlinks to the binary from e.g. /usr/bin (with definitions in /etc/alternatives).

One major advantage might also be using the left to right order in $PATH. E.g. when you override standard commands by local versions or scripts that perform prechecks (say a script that puts a warning before shredding files), one would have them in a directory that is listed at the beginning of $PATH, so the local (user's) version is run and the standard one only via its full path.

More on your question: Moving the binaries is not a good idea: they may rely on other files in their directory. Soft link them at most. Or just use the alternatives set of tools - which also helps in keeping more overview.


It depends...

If you've got hundreds of these programs, then perhaps.

Otherwise, since /usr/local/bin/ is in your $PATH, put your programs in a user directory somewhere sensible and place corresponding soft links for each program in /usr/local/bin/. It's not perfect, but avoids PATH mangling.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .