Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    /opt vs /usr/local +Program installation question

    I recently did something to damage my main system and while all my important data is partitioned out and safe all installed programs are not if what ever i did this time or what ever i might do in the future ( Im the DIY till it blows up in your face type that is trying to bone up on 30 years of culture and history in the GNU/Linux && Unix society while teaching myself for scratch how to be a linux system administrator. However in creating a hedge against future screwups and system upgrades i have come to the conclusion i need to do something. So i formulate a plan based on bunch of different sources of a compartimentalized partitioning scheme however as i stated earlier i was able to compartmentalize my data not the programs, which brings me to the crux of this very long and winding question. While unix has a configuration repositiory (/etc) that clean and simple i am still left with the question can i keep a bunch of programs either installed via package management, tarballs ect partitioned out on a nice safe directory if worse come worst and i corrupt my system so baddly that i need to jettoson my static binaries and configuratation files and start anew (which seems to be a good stratagy for an amature although definately not a productive one) could nonstatic nonsystem binaries come through something lilke unscathed by being self contained?
    (With windows that would be quite impossible if the program was in anyway interfaced with the registery and while /etc is no where as near as *#@$-up as the windows registery i just wonder if there are important files and more importantly could a program be told to regnerate those files on a new install if they existed)

    This leads me to my second question /opt vs /usr/local for nonsystem nonpackage binaries. I have read many articles on the subject recently and they say that they are pretty much for the same thing the differences come from the rich roots of linux where /opt is SysV and /usr./local is BSD /opt is for big endian system and /usr/local for little endian system. Intellectually i understand it and it all seems theoretical.. So im asking pratical opinions to anyone that might answer this post is there a difference and how does one differentiate the two.

  2. #2
    the binaries from one Linux system will work just fine on a new installation of that same Linux distro. It might even work on another distro that was released around the same time, but specifically, it depends upon the shared libraries that the binary was built against, and possibly upon kernel configuration.

    i.e., if you had one CentOS 5.2 box, built binaries for it, backed up those binaries, wiped out the system, reinstalled CentOS 5.2, then put those backed up binaries into place on the new system, they will run as well as they did before (provided that any libs or other dependencies are satisfied). if however, you installed CentOS 5.8, then don't assume the backed up binaries from the CentOS 5.2 box will run (they might, but don't assume it).

    where to install 3rd party software is a debate that you'll find if you look around on the 'net. For me, i prefer /opt. I like to be able to just "ls /opt" and see everything that i've installed at a glance. When you install stuff to /usr/local, things can get messy quickly. also, if RPMs support alternate install locations (they usually default to an install base of /usr), it is usually /usr/local, so that would cause more confusion if I was using /usr/local for manual installs, too.

    one nice feature of using /usr/local is binaries usually wind up in /usr/local/bin, which is usually already in the path of users. that means you have to either add a symlink to /usr/local/bin pointing to your binary (e.g. ln -s /opt/java/bin/java /usr/local/bin/java), or modify a login profile to add that path, or in the case of RH/CentOS/Fedora systems, use the alternatives program to specify where your program's binary is to be found.

    I like the 3rd option, but it is kind of convoluted, so if I'm in a hurry, I use the 2nd option. I almost never do the 1st option (create symlinks). For the 2nd option (modifying login profiles), a nice way to modify the path is to create a shell script that gets sourced by all users automatically, at login. This is true of files ending in ".sh" that are in the /etc/profiles.d/ directory. so in that dir, i could put a file called "" that might have this content:

    if [ -d /opt/java/bin ]; then
      echo $PATH|grep -q /opt/java/bin && : || export PATH=${PATH}:/opt/java/bin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts