Ubuntu – How to tell Ubuntu where to install a program and how to tell where an existing program was installed

aptinstallationserver

I'm totally new to Ubuntu/Linux, using Ubuntu Server at the moment. Just trying to figure out something basic.

How can you tell where you are installing a program. For example I just installed Sphinx search engine by placing the tarball that I downloaded from their site to my:

/home/sphinx

directory. I created the sphinx directory to place that tarball in. Then I ran these commands:

tar xvzf sphinx-0.9.8.1.tar.gz
cd sphinx-0.9.8.1/
./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql

and then these:

make
sudo make install

Now I have a lot of files sitting in the directory where I ran these commands. Is this my Spynx installation or did it install somewhere else?

In windows if you run an installer (.exe file) anywhere the program will still install in your C:\Program Files directory. Does something similar apply to linux where all programs are installed in a central place, or can you install programs anywhere on the system.

Questions

  1. I would prefer to keep all my installed programs in one place so
    what is the right place for this in terms of best practice. In
    other words what is the Linux equivalent of C:\Program Files?

  2. And how does one always install at this location, is it just a matter of placing the tarball and running the install commands from this location?

  3. What about if I use sudo apt-get to install a package. How can I point to this location to tell apt-get to always install there?

Best Answer

Does something similar apply to linux where all programs are installed in a central place

Approximate equivalents of Windows install directories in Linux

  • \Windows = /bin
  • \Windows\System32 = /lib and /sbin
  • \Program Files = /usr/bin and /usr/lib

I would prefer to keep all my installed programs in one place so what is the right place for this in terms of best practice. In other words what is the Linux equivalent of C:\Program Files?

That would be the directories under /usr, specifically /usr/bin and /usr/lib.

And how does one always install at this location, is it just a matter of placing the tarball and running the install commands from this location?

  • No. Where you are when you run the install commands almost never matters.

  • Programs you install via apt-get (or aptitude) will almost always end up appropriately in /usr. BUT programs you compile from source and make install will more often end up in /usr/local/bin, /usr/local/lib, etc, and you may have problems with that since the user-installed path in Debian/Ubuntu is /usr and not /usr/local.

  • When compiling from source, add this switch to configure: ./configure --prefix=/usr. This way when you make install the files will end up in the right directory

  • Also look into the checkinstall program, which keeps track of the files a package compiled from source installs, makes a deb file, and allows for easy uninstall/reinstall.

What about if I use sudo apt-get to install a package. How can I point to this location to tell apt-get to always install there?

apt-get/dpkg take care of this automatically. You can use dpkg -L name-of-package to see all the files installed by a package and where they were installed.