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.

  1. 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).

  2. 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.

    Dag Wieerswww.apt-get.org
    livnaDebian Multimedia
  3. 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.
There are two levels of package management on linux.
  1. Individual packages are managed by rpm and dpkg on Red Hat and Debian respectively, the common operations being listed below

    DebianRed HatDescription
    dpkg -Gi package(s).debrpm -Uvh packages(s).rpminstall/upgrade package file(s)
    dpkg -r packagerpm -e packageremove package
    dpkg -l '*spell*'rpm -qa '*spell*'show all packages whose names contain the word spell
    dpkg -l packagerpm -q packageshow version of package installed
    dpkg -s packagerpm -q -i packageshow all package metadata
    dpkg -I package.debrpm -q -i -p package.rpmshow all package file's metadata
    dpkg -S /path/filerpm -q -f /path/filewhat package does file belong
    dpkg -L packagerpm -q -l packagelist where files were installed
    dpkg -c package.debrpm -q -l -p package.rpmlist where files would be installed
    dpkg -x package.debrpm2cpio package.rpm | cpio -idextract package files to current directory
    dpkg -s package | grep ^Depends:rpm -q --requires packagelist files/packages that package needs
    dpkg --purge --dry-run packagerpm -q --whatrequires packagelist 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
    Note the sizes are reported in bytes on RPM distros and kilobytes on DEB distros.
    FSlint gives the same functionality but normalizes the units and
    also has support for auto selecting packages for deletion based on dependencies.
  2. 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.

    DebianRed HatDescription
    apt-get dist-upgradeyum 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.
Note for a similar comparison of packaging commands see Arch Linux' packaging rosetta.
© Jun 8 2006