Getting Started with Linux – Package Management
One of the most annoying parts of installing a software package is finding you need to install three or four extra bits and pieces before the initial program will install. I’m sure we’ve all seen it before; when installing software in windows, it will require a version of .net runtime to be installed, for example, necessitating a hunt for the relevant package.
One of the greatest things that Linux brought to the software world is the package management system.The Unix software idea, which Linux was built atop, was the idea of many small software packages doing specific tasks.This philosophy gave rise to a large number of packages that would depend on many other packages in order to work.This could obviously lead to a small nightmare when you needed to locate all the various packages that you needed for your desired application.The package manager uses a database of applications in order to work and in order to install the requested application and all its dependencies in one hit for you.
The advantages of this are that, for most Linux package managers, the database is one of various pre-compiled applications that are all tested against each other. So, in theory, anything installed from the package manager that ships with your version of Linux should “just work” on your system. This can dramatically reduce time spent chasing bugs and solving problems. Not all applications you may want will be in the repositories that the package manager will ship with, but you can usually add further repositories for extra packages, or in some cases, download package files from the software creator that will use your existing package manager to install and find dependencies.
Package managers also massively simplify the tasks of keeping the software on your server up to date. Rather than having to monitor all the separate application sources for patches and updates, the team behind the Linux distribution you use will do all that. They’ll test the patches and then distribute the updates through the package management system, meaning that one simple command can update all the packages on your system.
The most common distributions we see in use on our servers are CentOS, Debian and Ubuntu. CentOS uses the Yum package manager, whereas Debian and Ubuntu use the Aptitude package manager.
Below are a few basic commands to help you get started with the package managers. Note that all package management needs to performed with root privileges so you either need to use the root account for this or prefix the commands with sudo. For any text within <> brackets, replace that text and the brackets with the text you wish to use.
To install a package…
Yum: yum install <package_name>
Aptitude: apt-get install <package_name>
To update the package manager database (Yum does this automatically each time it is used)…
Aptitude: apt-get update
To update all packages…
Yum: yum update
Aptituge: apt-get upgrade
To upgrade the entire system…
Yum: yum upgrade
Aptitude: apt-get dist-upgrade
To search for a package. This is handy if you know the name of the application but not its package name…
Yum: yum search <name>
Aptitude: apt-cache search <name>
To show installed packages…
Yum: yum list installed
Aptitude: dpkg –list
To get further information on a package…
Yum: yum info <package_name>
Aptitude: apt-cache show <package_name>
To see which package installed a particular file…
Yum: rpm -qf filename
Aptitude: pkg –search filename
To see which package will provide a specific file…
Yum: yum provides <filename>
Aptitude: apt-file search <filename>
There are more things you can do with the package management systems, but this list should cover the basics for the vast majority of users.
Happy package managing.