I have noticed that a very confusing concept for users
transitioning from windows to linux is packaging.
There are three reasons for this as far as I can see.
- Traditionally windows programs have been released as
an executable installer that contain any required
dependencies (libraries etc.). There are many problems
with this method, the most obvious being:
- No standard install API so can't do many things like seeing where a file came from etc.
- Size of install files large due to included dependencies and install logic
- Large burden on developers to develop install logic
Microsoft have addressed these problems with MSI files, which are essentially the same as linux packages. However MSI files are still autonomous. I.E. they don't handle dependencies and so still suffer from the second problem above (though to a lesser extent as they don't need to include install logic).
- The windows filesystem layout generally puts all files
associated with a program under one directory (usually in "Program files").
There are many problems with this also, the main one being that
this leads to mixing of logic and data which is very inflexible.
Note there are linux distributions that simulate this while not losing the
advantage of the traditional unix method. See gobolinux for example.
Generally for linux packages, the executables are copied to /usr/bin, the libraries to /usr/lib and the docs to /usr/share/doc/$package/. You may think that this is impossible to manage, with files sprinkled across the filesystem like this. However the package management system tracks where all the files are, allowing the user to easily uninstall etc. Also one can easily see the dependencies between packages, and are automatically told if an operation on a package would conflict with the rest of the system.
It's worth noting here that to take full advantage of the package management system, one should not go installing or deleting files behind its back. For e.g. only install from source as a last resort. In the unlikely event you can't find a package on the net, it's not too hard to make the package yourself. The following are good starting points for looking for packages.
RPM DEB rpmfind.net packages.debian.org Dag Wieers www.apt-get.org livna Debian Multimedia - There are multiple different package management systems in the linux world, the two main ones being Red Hat and Debian. These two are functionally equivalent though, and will be compared below.
- Individual packages are managed by rpm and dpkg on Red Hat and
Debian respectively, the common operations being listed below
Debian Red Hat Description dpkg -Gi package(s).deb rpm -Uvh packages(s).rpm install/upgrade package file(s) dpkg -r package rpm -e package remove package dpkg -l '*spell*' rpm -qa '*spell*' show all packages whose names contain the word spell dpkg -l package rpm -q package show version of package installed dpkg -s package rpm -q -i package show all package metadata dpkg -I package.deb rpm -q -i -p package.rpm show all package file's metadata dpkg -S /path/file rpm -q -f /path/file what package does file belong dpkg -L package rpm -q -l package list where files were installed dpkg -c package.deb rpm -q -l -p package.rpm list where files would be installed dpkg -x package.deb rpm2cpio package.rpm | cpio -id extract package files to current directory dpkg -s package | grep ^Depends: rpm -q --requires package list files/packages that package needs dpkg --purge --dry-run package rpm -q --whatrequires package list packages that need package (see also whatrequires)
More complicated commands I find useful are to list all packages by size on RPM and DEB distros respectively:
rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
FSlint gives the same functionality but normalizes the units and also has support for auto selecting packages for deletion based on dependencies. - At a higher level, package dependencies can be automatically
managed by yum and apt.
With these tools one can essentially say "install this package" for e.g.
and all dependent packages will be installed/upgraded as appropriate.
One of course has to configure where these tools can find these
packages, and this is typically done by configuring online package repositories.
Debian Red Hat Description apt-get dist-upgrade yum update [package list] upgrade specified packages (or all installed packages if none specified) apt-get install <package list> yum install <package list> install latest version of package(s) apt-get remove <package list> yum remove <package list> remove specified packages from system apt-cache list [package list] yum list [package list] list available packages from repositories
Note Debian requires one to `apt-get update` before these commands so the local cache is up to date with the online ones.
Yum is the opposite, in that one needs to add the -C option to tell it to operate on the local cache only.