How to set the path where sudo apt-get installs
Summary
- You shouldn't, and basically can't, make the package manager put any file anywhere except its default location.
- You can find the location of just about any program (i.e., the executable file itself) with the command
which filename
or by searching in Nautilus.
Details
You cannot change the default locations to install software with apt-get
, the Software Center, or the other package management tools in Ubuntu. You can manually retrieve packages and extract their files wherever you want, but you almost certainly wouldn't want to do that. Generally speaking, it's a hassle and there's typically no reason to do it.
- If you believe you would benefit from doing this, please add details to your question about why, an what you need to accomplish. The best way to do it would depend on that, plus there may be alternatives you haven't considered.
Packages install files throughout the filesystem, mostly in different subdirectories of /usr
. This is in accordance with the filesystem hierarchy standard which specifies where different kinds of files, associated with installed programs and libraries, are supposed to go in a GNU/Linux system (i.e., in a "Linux distribution," like Ubuntu).
- The executable files themselves go mostly in
/usr/bin
. That's where theeclipse
executable is installed when you install theeclipse
package on Ubuntu. - Executable files for games often go in
/usr/games
instead. - Executable files for system services like NetworkManager usually go in
/usr/sbin
instead. (s
stands for "system". These are "system binaries.") - Libraries mostly go in
/usr/lib
. - If you have a 64-bit Ubuntu system, 32-bit libraries (installed to support 32-bit executables, since a 64-bit system can run both 64-bit and 32-bit programs) mostly go in
/usr/lib32
. - Header files, which facilitate building software from source that links to installed libraries, mostly go in
/usr/include
. These files are provided by packages whose names end in-dev
. The exception is the headers for building kernel modules--those go in/usr/src
. - Source code installed for systemwide use for packages that provide it goes mostly in
/usr/src
. Header files for building kernel modules also go here. - Systemwide data files (i.e., not executable code, but data) for installed programs and libraries, when it is architecture-independent (for example, doesn't depend on whether you have a 32-bit or 64-bit processor), mostly go in
/usr/share
. Please note that this is for data files that remain unchanged except when the package itself is updated, not documents you create. For example, the master lists for spellchecker dicationaries (but not user-specific additions to them) will usually go in/usr/share
. - Systemwide configuration files for virtually every package (and most software not installed through the package manager, too) go in
/etc
.
You'll notice I keep saying "usually." This is because:
- Core system files, including the most essential programs and libraries for the system to function, don't go inside
/usr
. They go in the corresponding subdirectories of/
itself. For example, core files that provide basic system utilities go in/sbin
. Core system files that provide basic "user" utilities, like the shells provided by default with the system, go in/bin
. Core libraries go in/lib
. And so forth. - Occasionally a package may install files in some other location. The most common such place is
/opt
. The main purpose of/opt
is to store (1) programs that choose not to spread their files around to the ordinary places in the filesystem heirarchy, but instead all in a single directory (whether or not these programs are installed using the package manager), and (2) programs installed by binary installers, not through the package manager, and don't have a package associated with them. (Programs installed for systemwide use by being built manually by the user from source code are ordinarily installed in the directories inside/usr/local
.)
There are a few ways to search for executables and other files provided by Ubuntu packages.
-
I don't know of a way to use the Unity Dash to tell you the location of a program in an accessible way. But you can accomplish this graphically with Nautilus, the graphical file browser.
- Open a Nautilus window and press Ctrl+F (or click Go > Search for Files...).
- Type in what you're searching for (in this case,
eclipse
) and press Enter. - By default this will search just in the folder that is open in this particular Nautilus window. But you can change that. After searching, change the Location to Filesystem (or to wherever you want to search, you could even specify the custom search location
/usr
) and click Reload.
This is how you search for files on your system in general (i.e., not just those provided by Ubuntu packages), with the ability to get detailed information about them.
-
Using the Terminal (Ctrl+Alt+T), you can find executables like eclipse with
which
:which eclipse
which
tells you which executable (if any) would be run if you typed eclipse and pressed enter in the Terminal. This is quite often, but not always, the same as the first search result when you search for the same thing in the Unity dash. -
Using the Terminal, you can find files quickly with
locate
(as the database that keeps the list is updated periodically). This is especially good when you want to find a file that is provided by a package, but is not actually an executable.locate eclipse
-
You can search through the files provided in Ubuntu packages at packages.ubuntu.com. There are other ways too.
I fear it is not possible to do that from the dash. If you want to know where the executable path is, you can use the which command:
which eclipse
But this will probably point to some "bin" directory, and not to the directory containing the data. That's because software components are not installed in a single directory, but across many folders. Binaries stay in /usr/bin/, /bin, /sbin, etc depending on their use. Configuration in /etc, data in /usr/share, etcetera. Refer to this document about Filesystem Hierarchy Standard and the reason while you usually don't have a single-folder installation. As apt follows FHS, as far as I know it is not possible to force it to install in different location.
So about where is eclipse installed, it depends on which part of eclipse you are searching for. A common need is to install plugins, which are stored under: /usr/lib/eclipse/plugins. I usually prefer the integrated plugin manager, anyway.