Where is installed software stored in Linux? [duplicate]

Possible Duplicate:
Where is a typical Linux program installed

I'm new to Linux and I want to ask a bit more about packages.

In Windows, I download an .exe file and install it. When I install, I define the path where I want that application to be stored. In that folder, I have all the files required for the application.

However, when I install a package in Linux using yum or apt-get, I don't know where the package is installed to and where the required files for that application are stored. I have seen that most of the configurations are in the /etc directory. But why does Linux store the required files for an application in different directories?

Can someone tell me how packages are installed, and where and how are they stored? And if my understanding about package management is wrong, please correct me.


Solution 1:

Many programs (the binaries/scripts) end up in /bin or /usr/bin with other parts in various configuration directories (often in/under etc) as you already noted.

For any specific command you can checkout whereis

whereis prog_name

and it will give you some information about where this command is to be found. You can also try which

which prog_name

Also, this graphic and explanation/examples might be helpful.

Solution 2:

Under Windows, particularly older versions, it was common for programs to store configuration files and non-constant data in their C:\Program Files directory. This is derived from how programs were usually installed and ran under single-user, non-networked, non-file-permission DOS.

From a security standpoint, this is a bad idea. Places where executable code lives should be separated from modifiable data. That way it's easier to apply appropriate file permissions to prevent modification of installed binaries by unauthorized users. Similarly library directories which may be updated separately from main executables should also be in a separate directory.

With the advent of Vista and UAC annoyances, this tradition is finally starting to seriously lose traction.

UNIX, and Linux, being a multiuser system from much earlier on, had the tendency to separate executable directories from other directories much earlier, since there was a need to prevent users other than root from modifying installed binaries. It's also why /usr and even /sbin are sometimes separate partitions - a particularly security conscious admin can mount those partitions readonly and remount them read/write when an install/uninstall needs to happen.

Packages are usually installed from a package manager. There's various package managers, such as aptitude (Debian and derived distributions), yum (Redhat and derived distributions), pacman (forget which distro this is...), and others.

The package manager lets you browse repositories, download, install, query, and remove software, much like a sophisticated (and free) "app store." It assumes responsibility for ensuring dependencies are taken care of and tracking what is currently installed.

Usually the package manager will also allow the same operations on a package you downloaded manually outside of any repositories. Tools are also available if you want to create your own from software you made or compiled yourself.

Since the package itself is NOT an executable file, you don't have to run an untrusted executable which you don't really know what it does. (Windows is finally coming around with updates by distributing .msu's instead of .exe's - but .msi's have been around a while...)

Solution 3:

You can get a list of the files that a given yum package installs by doing:

yum install yum-utils

Then you can run it like so:

repoquery --list yum-utils

(Obviously, replace "yum-utils" in that second one with the name of that package whose file list you'd like to see.)

For apt-get, you can use:

dpkg -L package-name