Friday, November 18, 2011

SkyHi @ Friday, November 18, 2011

Command line package administration can be powerful but it’s not obvious at first glance.
The commands to list, install, upgrade and uninstall are not using the same shell command.
Sometime you need apt-get, sometimes apt-cache, sometimes dpkg,… not very consistent.
Some commands are also confusing, for instance:
1bash# apt-get install phpmyadmin
will install only the phpmyadmin package.
However this one:
1bash# apt-get upgrade phpmyadmin
or this one:
1bash# apt-get upgrade
are exactly the same and will attempt to upgrade ALL your packages, and not a specific one.
apt-get upgrade should probably give an error that is has an extra argument instead, otherwise you think you’re just upgrading one package.
Worse: you need to reuse the apt-get “install” command to upgrade a specific package, which makes the “upgrade” keyword confusing.
This cheat sheet is also valid for Debian systems as Ubuntu is based on Debian.
It is presented in a chronological manner for the lifetime of a package: searching, getting more details, installing, upgrading, removing.
Here is a quick cheat sheet summary:

1/ Package Management Cheat Sheet

sudo apt-get update # Update the local repository to have all the latest available packages
apt-cache search phpmyadmin # Search by keyword for a package
apt-cache show phpmyadmin # Get more information about a specific package before installing it
sudo apt-get install phpmyadmin # Install a specific package
dpkg -L phpmyadmin # List the files installed by a specific package
dpkg -l # List ALL installed packages
sudo apt-get install # Upgrade a package to the latest available version
apt-get upgrade # Upgrade ALL installed packages
sudo apt-get remove phpmyadmin # Uninstall, Remove, Delete, Suppress, Deinstall a specific package
And here are what the commands return in detail:

2/ Update the local repository to have all the latest available packages

1bash# sudo apt-get update
2Hit http://us.archive.ubuntu.com maverick Release.gpg
3Ign http://us.archive.ubuntu.com/ubuntu/ maverick/main Translation-en
4Ign http://us.archive.ubuntu.com/ubuntu/ maverick/main Translation-en_US
5Get:1 http://security.ubuntu.com maverick-security Release.gpg [198B]


REFERENCES
http://blog.bottomlessinc.com/2011/01/ubuntu-basic-command-line-package-administration-cheat-sheet/