How to tell Ubuntu where to install a program and how to tell where an existing program was installed?
Solution 1
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
(oraptitude
) will almost always end up appropriately in/usr
. BUT programs you compile from source andmake 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 youmake 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.
Solution 2
Usually programs are installed in a couple of directories under one top directory, called a prefix. Which top directory to use depends on who is installing, for what purpose and who will manage the software.
The prefix /usr
is used software packed by your distribution. You should not install any other software there, because it will confuse the distribution when installing and upgrading software packed by the distribution.
For commercial software, the prefix /opt
is used. It's reserved for them to interfere least with distributions and the local system administrator.
For software the system administrator installs for all users, the prefix /usr/local
is used.
If you are an ordinary user installing software for yourself, you could use your home directory as prefix, by using the --prefix
option to configure
with prefix directory "~/
" or $HOME/
. I used that a lot when I was a student. :-)
Usually software does the right thing when you execute configure
with the option --prefix
with the right value and then make; make install
.
Under any of these prefixes, you usually find these directories in a standard installation.
-
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 with default values for the software. -
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 log files etc.
Most of those directories can be used with write protected file systems to increase security. The only one that users need to write to is the var/
directory.
When the software is updated these directories need to have write privileges. Usually one does not need to do anything, but if needed that can be done with a remount with write privileges during installation and then remounted with read only after installation. But this is advanced, and I only give it as an example of advanced package management.
There are also some directories directly under /
(the root directory) which don't exists under any other prefix, like /dev
, /tmp
, /proc
and /srv
(for server data directories, but they are usually under /var/lib
or /var/www
and directories like that, so you need to change configuration to use this directory. I do recommend that you do that when you are running a server. Only use /var/
for testing out a standard installation).
Different programs have different installation methods. --prefix
is useful for programs using configure
. Best way to know is probably to read the README.txt
file or something like that, which is probably provided with in the tar archive.
The tar archive can be extracted in any place, like your home directory. After the installation steps are done, you can remove the extracted tar archive if you are short of storage. But it's better to keep the directory as you can often use it for uninstallation.
Programs installed with apt-get
or aptitude
are always installed in the proper place for the distribution. You can't change that place.
Solution 3
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.
![Sheik](https://i.stack.imgur.com/dxAuh.jpg?s=256&g=1)
Sheik
Updated on September 18, 2022Comments
-
Sheik over 1 year
I installed SAP netweaver 7.02 trail from scn.sap.com. Installed it with youtube tutorial. worked fine for few hours. Later When I switch on management console it turns green and then turns back to yellow in few seconds. I couldn't access with sapGUI from other user which I did before few hours. GUI's error message is "partner '127.0.0.1:sapdp00' not reached".
-
vwegert over 11 yearsWhich processes are breaking down? What else is in the logs?
-
Sheik almost 11 years@vwegert saw some database errors in log. Anyways now formatted the system. Now using some demo version. Sorry for late reply.
-
Anders over 2 yearsYou installed them somewhere else when you did
make install
, which probably are under/usr/local
, which is the proper, traditional way to install your programs compiled from source. So it doesn't get in the way for the distribution and other software. There are there for a reason, like Linux isn't MS Windows, and you will probably be unhappy if you treat Linus distributions like they was MS Windows. MS Windows is a single user OS, Linux is not. That is why there are different directories for binaries (programs). If you want to change that, you better make your own distribution.
-
-
Anders over 2 yearsYou should NEVER install something under
/usr/bin
etc in Debian and other distributions, as that will certainly confuse and possible ruin your installation. You should install programs compiled from source by system administrator under prefix ´/usr/local/` like/usr/local/bin
etc. Because there it are they supposed to be located when compiled and installed by the local administrator/user for all users on the machine to use, and usually are looked before/usr/bin/
etc. Or install in your$HOME/bin
if you don't have write access and don't want others to use. -
Anders over 2 yearsRed Hat et al make it possible to install under
/usr/bin
etc. But they still have a/usr/local
prefix that works. So really. User/administrator compiled programs that you want to make available for all users should be installer under prefix/usr/local
not/usr
nor/
. And there are many good reasons for that. Except for that, an ok presentation. And yes, MS Windows isn't made to be used by many users, which shows... -
Anders over 2 yearsYou could added that a prefered prefix to install local programs are under
/usr/local
or$HOME/
. Depending what privileges you have. If you develop programs, you should really use a prefix to where you compile and install program.s And one should probably set prefix when compile, so paths in programs get right values.