Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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 will almost always end up appropriately in /usr. BUT programs you compile from source and 'make installwill 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.

share|improve this answer
    
thanks for the detailed answer, just one question. Since you said "No. Where you are when you run the install commands almost never matters.", does this mean now that I have installed the program I can safely delete the Sphinx folder in /home/sphinx/ that I extracted from the tarball and ran the install and made commands in? Is this now the equivalent of an installer that I already ran to install a program and now has no use? –  JakeRow123 Jun 14 '12 at 2:39
    
Yes, you can delete the folder extracted from the tarball -- it's essentially like a "temp" folder the installer was extracted to and is now useless. That was a great question, I will edit the answer to include this info. –  izx Jun 14 '12 at 3:04
    
You could, but then you will have problems uninstall them with 'make uninstall'. In Debian/Ubuntu you should never install your software in prefix / or /usr, you should use /usr/local. Why, because /usr/local is created for local administrators, that's you JakeRow123, to install their own programs. / and /usr is for Debian packages only. If you install there, the chanses are big that you will get problems. So use the switch '--prefix=/usr/local' to the command configure when you compile you own. Then 'make; sudo make install' will install you program there. –  Anders Jun 14 '12 at 21:41
    
@Anders, make uninstall is NOT a standard feature and is not found in lots of program sources. Also, /usr/local is often not in the path on Ubuntu and may cause problems when trying to run programs or trying to compile (because of includes in /usr/local). –  izx Jun 15 '12 at 0:30
    
You should NOT install software in the wrong place, like under /usr and not in the right place like /usr/local. You should fix the fault with the PATH if computer/users environment isn't set up correctly. Installing under / or /usr WILL get you into trouble. Belive me on this. Been there and done that. It was NOT any fun. At all. Some programs, all with autoconfig, wher you set up with the configure command got an uninstall. Others that don't have that is not helpfull, and should have a bug reported... –  Anders Jun 15 '12 at 1:49
show 2 more comments

When you install programs from a repository using the normal install, it will install to the correct place, create configuration files in the right place (functionally similar to Windows registry), and create menu entries automatically.

When you download a file (non-preferred, but often necessary when the app isn't in a repository), then the first thing you did was to run tar, equivalent to unzip on Windows. This creates the files you are most likely seeing.

Then, when you run make install, that will usually put the results in the right place, maybe create menus, but it won't erase the un-tarred files. You can most likely do that, but you may want to save them temporarily just in case.

Here is an interesting article on Debian Directory Structure.

share|improve this answer
    
Nice article, except that it didn't had any reference to /usr/local where you install your own software to not conflict with software installed by system and you distributions (like Ubuntu) packages. To install you own software under / or /usr is to ask for problems, problems which probably only sollution is to install the system from scratch again... –  Anders Jun 17 '12 at 23:11
add comment

Usually program are installed in a couple of directories under one "master" directory, called a prefix. Usually the prefixes are "/" and "/usr" for system and for your distribution packed software. For commercial software, the prefix "/opt" is usual. For software you compile or write youself, the prefix "/usr/local" is created. Use that, or the risk is large that you will get conflicts with software installed by you distribution (OS).
If you aren't a system administrator of the machine, you can install the software in your own directory, using the prefix "~" or "$HOME". I used that a lot when I was a student. :-)

Usually software do the right thing when you execute 'make install'.

Under any of these prefixes, you usually find these directories.

  • bin - the executable programs, binaries.
  • sbin - system binaries, which usually should not be executed by ordinary users.
  • man - manual pages for programs, libraries and config files etc.
  • etc - config files.
  • lib - program libraries and data files that are dependent on architecture (like the CPU) in your computer.
  • share - data files that are not different on different architectures, and can be shared between different computers.
  • var - directories with data that changes during program execution. Like logging files etc.

Most of those directories can be on write protected file systems, except the var directory. They obviously(?) need to be open for writing when upgrade/install software though.

There are also some directories directly under '/' which don't exists under any other prefix, like /dev, /tmp, /proc and /srv (for server data directories).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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