Generally speaking, under Linux, /usr
is for programs provided by the distribution and managed by its package manager (dpkg/apt, rpm/yum, emerge, etc.) and /usr/local
is for programs installed and managed manually by the system administrator. Programs under /usr
and /usr/local
are installed for all users.
If you want to install programs for your own use, put them somewhere under your home directory.
I recommend using Stow or XStow to keep track of the programs that you install manually. (Use one or the other: they are implementations of the same concept.) When you install programs manually, you have a choice between two inconvenient options:
- Put all programs in the same directory. Then you'll have a hard time sorting them out, figuring which files belong to which programs, uninstalling programs, etc. On the flip side, all programs are easy to use: you only need to update your PATH and other similar settings once.
- Put each program in its own directory. Then uninstallation is as easy as
rm -r
. The downside is that you have to add each program to PATH and so on.
Stow gives you the best of both worlds. This tool maintains symbolic links from a common directory to a per-program directory. You install each program (from source or from a binary package) in its own directory under stow
, and Stow creates symbolic links in bin
, lib
, man
, …
So create a directory programs/stow
under your home directory. Install netcdf with
./configure --prefix=~/programs/stow/netcdf-gfortran-4.3
make
make install
Then run stow netcdf-gfortran-4.3
from the ~/programs/stow
directory to create symbolic links for all the parts of that package.
Edit your .profile
(or wherever you put your environment settings) to add ~/programs/bin
to your executable search path, ~/programs/lib
to your library search path, etc.
PATH="$HOME/programs/bin:$PATH"
if [ -n "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH="$HOME/programs/lib:$LD_LIBRARY_PATH"
else
export LD_LIBRARY_PATH="$HOME/programs/lib"
fi
if [ -z "$MANPATH" ]; then
MANPATH=$(manpath)
fi
export MANPATH="$HOME/programs/share/man:$HOME/programs/man:$MANPATH"
When compiling programs, pass --with-cppflags="-I $HOME/programs/include"
to configure
so that it can find headers in the stow area.
For more information, see Keeping track of programs and What is an effective method for installing up-to-date software on an out-dated production machine?