I have gone through a related thread here.

A colleague of mine has copied the phantomjs binary to /usr/bin. In our system, this binary will be used only by a non-root user. At the moment, the regular user is able to run this binary fine, but going to the thread posted in this question, it does not like a right thing to put a binary used by a non-root user under /usr/bin. So is there any reason for me to move it from /usr/bin to /usr/local/bin or is it better to leave it at /usr/bin? In other words, would it make any difference to a binary if it is put under /usr/bin or /usr/local/bin or it is a 'rule' that is generally followed?

[root@seco01 ~]# which phantomjs /usr/bin/phantomjs [root@seco01 ~]#

P.S: /usr/local/bin is included in the $PATH.

  • 2
    Leave it in /usr/local/bin. Locally installed stuff should be in /usr/local/bin, not in /usr/bin, per the FHS. – Faheem Mitha Jan 21 '15 at 7:53
  • That is what I had planned to do, but thought I will check here first to see if there is any other strong reason why it shouldn't be in /usr/bin since this binary is currently being used actively in some of our systems. – Citylight Jan 21 '15 at 8:02

The Filesystem Hierarchy Standard says, per /usr/local : Local hierarchy, that

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

As a general rule of thumb, in modern Linux distributions, software that is managed by the distributions package manager uses /usr/bin etc., while /usr/local/bin is used by local installations of software that is not managed by the package manager. The typical case here is software that is installed via make, make install. Static stand-alone binaries also fall into that category.

Another possibility is /opt. The division between /opt and /usr/local is not clear, but /usr/local is more customary for local installations. Here is what the FHS says about /opt:/opt : Add-on application software packages.

  • Thanks. I created a folder under /usr/local, moved the binary to there and added the path to $PATH. – Citylight Jan 21 '15 at 9:53
  • @sree you should not need to add /usr/local/bin to PATH. It should already be there. Here is my PATH (on Debian wheezy). It is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. I think that is the Debian default. – Faheem Mitha Jan 21 '15 at 11:27
  • What I did was I created a folder /usr/local/phantom-xx-6.x and added `/usr/local/phantom-xx-6.x/bin to $PATH. Yes, /usr/local/bin is already in the $PATH. – Citylight Jan 21 '15 at 16:38
  • @sree You could just put the binary in /usr/local/bin. – Faheem Mitha Jan 21 '15 at 16:39

If it is only used by a local user then I think that there is no point in keeping it in /usr/bin. This also makes it safer to access.

Link posted by you also says that it is as per FHS (Filesystem Hierarchy Standard).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.