When I patch one of my Linux systems or add new software, 99 times out of 100 I use a modern program like the Ubuntu's Software Center or Linux Mint's Software Manager. But there are times, especially when I'm working with a system that needs automated updates using cron or with a remote system via ssh or telnet, that I need to use a good, old-fashioned command line tool—and you will too. So, for times like those, it helps to keep the shell commands in mind.
Software Manager: Software management programs like Mint's Software Manager look great, but they're not too practical on servers, local or remote, or if you want to put update commands in your cron file.
Most Linux distributions have similar tools... but there are key differences.
Debian/Ubuntu Linux family
The Advanced Packaging Tool (apt) is the fundamental software installation and patch tool for the Debian/Ubuntu Linux family. It works above dpkg, this family's main program package management program. It’s built into most Linux installations.
Typically, you won't use apt by itself. Instead, you use the apt-get utility for day-to-day work. As its name suggests, this command lets you “get” patches and new programs.
Aptitude: On Debian and Ubuntu-based systems you don't need a GUI for a menu-based software management and update program, thanks to the aptitude program.
Some popular uses for the apt-get utility include:
Install a Package: Installation of packages using the apt-get tool is quite simple. For example, to install my favorite e-mail program, Evolution, I'd type the following into my shell:
sudo apt-get install evolution
Remove a Package: If I no longer want that program, say I want to turn a former desktop system into a server, I'd remove Evolution by typing in the following:
sudo apt-get remove evolution
Let's say I know I'm never going to run evolution on that system again. In that case I'd add the --purge options to the apt-get remove command to delete the package configuration files as well.
Update the Package Index: Programs are constantly being updated in Linux. To keep your system up to date, you first should update the apt package index, a listing of available packages from the software repositories you've defined in the /etc/apt/sources.list file. To update this local package index with the latest repositories changes, use the following command:
sudo apt-get update
Upgrade Packages: Then to update your system's installed software, you run the following program. Everything in your systems will be updated with the following command:
sudo apt-get upgrade
Notice that in all the above examples you need to use the sudo command. This command is most commonly used to give trusted ordinary users the power to run a single command as if they were the “superuser,” a.k.a. the root user or system administrator.
By default, Ubuntu and its descendants, like Mint, don't have a root account. Debian, however, does. Thus, to run any top level management jobs in Ubuntu you must use sudo. You could run apt-get in Debian-based distributions as root, but it's never a great idea to run common jobs as root since the system administrator has so much power in Linux (and in other operating systems too, of course).
Let's say though that you want a more interactive way to update your Debian or Ubuntu based system, but you still don't have access to a GUI. In that case what you want to use is aptitude. This program uses the ncurses programming library to create a character-user interface for terminals.
Personally, I almost never use aptitude these days, but there are still times that having an easy-to-use package management interface is darn handy so I always keep it on my Debian-based systems.
Red Hat Family
Like the Debian family, Red Hat Enterprise Linux (RHEL) and its relatives, such as Fedora, CentOS, and Scientific Linux, have a command line option for updates. While older versions of the RHEL family used up2date, the current program is the rather oddly named yum.
Yum: Red Hat's answer to apt-update makes installing programs from the shell easy.
Yum, which comes from Duke University, is an acronym for Yellowdog Updater Modified. Yellow Dog was, and still is, a Red Hat Linux-based variant for POWER-based computers. Today, yum, along with Red Hat's RPM Package Manager (RPM) (Yes, it's a recursive acronym; welcome to Linux!), is the equivalent of apt-get.
In Red Hat's case, RPM refers both to the package format and to the software used to manage it at a low level. Like dkpg you can use it by itself to update and install programs but that's not a great idea. You see, RPM installs just the program you ask for; it doesn't bother with such details, such as as any libraries your program of choice might need. That's why yum plays the role of apt-get in Red Hat circles.
One difference is that typically in Red Hat you run all the rpm and yum commands as root.
Install a Package: Installation of packages using the yum is also quite simple. For Evolution, I'd use the following shell command:
yum install evolution
Remove a Package: To delete Evolution you'd type:
yum remove evolution
Upgrade Packages: Again, like apt-get, you can easily update your system's installed software with a single command:
SUSE Linux, and its relatives like openSUSE, also use RPM, but instead of yum, these Linux distributions use the command zypper. Over the years, SUSE has experimented with many software update tools, so I'm glad they finally settled on this one.
Zypper's basic syntax should look very familiar by now.
Install a Package: Picking on Evolution once more, in SUSE land, the command is:
zypper install evolution
Remove a Package: To delete Evolution you'd use the following command:
zypper remove evolution
Upgrade Packages: And, again it's easy to update your system's installed software:
Updates from 20,000 feet
Don't let these surface resemblances fool you. Once you go beyond the basics, each distribution’s command line software management programs act in very different ways. So, before jumping from one distribution to another, never mind from one Linux family to another, always check how your distribution's specific commands work.
If you don't... Well the least that can happen is that the commands won't work. At worst, there's no telling what kind of junk you could put on your system.