\documentclass[twocolumn]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0pt}{2\baselineskip}%
{\baselineskip}{\large\sffamily\centering}}
\makeatother
\setcounter{secnumdepth}{0}
\catcode`<=13
\def<#1>{$\langle${\itshape #1}$\rangle$}
\lhead{APT and Dpkg Quick Reference Sheet}
\rhead{\textsc{Matthew Danish}}
\begin{document}

\section{Common APT usage}

\paragraph{apt-get install <package>}

Downloads <package> and all of its dependencies, and installs or upgrades them. This will also take a package off of \textit{hold} if it was put on. See below for more info on \textit{hold.}

\paragraph{apt-get remove [-\/-purge] <package>}

Removes <package> and any packages that depend on it.  -\/-purge specifies that packages should be \textit{purged}, see \texttt{dpkg -P} for more information.

\paragraph{apt-get update}

Updates packages listings from Debian mirrors, should be run at least once a day if you install anything that day, and every time after \textsf{/etc/apt/sources.list} is changed.

\paragraph{apt-get upgrade [-u]}

Upgrades all packages installed to newest versions available. Will not install new or remove old packages. If a package changes dependencies and requires installation of a new package, it will not be upgraded, it will be put on \textit{hold} instead. \texttt{apt-get upgrade} will not upgrade packages put on \textit{hold} (that is the meaning of \textit{hold}). See below for how to manually put packages on \textit{hold}. I suggest the `-u' option as well, because then you can see what packages are going to be upgraded.

\paragraph{apt-get dist-upgrade [-u]}

Similar to \texttt{apt-get upgrade}, except that \textit{dist-upgrade} will install or remove packages to satisfy dependencies.

\paragraph{apt-cache search <pattern>}

Searches packages and descriptions for <pattern>.

\paragraph{apt-cache show <package>}

Shows the full description of <package>.

\paragraph{apt-cache showpkg <package>}

Shows a lot more detail about <package>, and its relationships to other packages.

\paragraph{synaptic \\ gdebi \\ gdebi-kde \\ dselect \\ aptitude \\ gnome-apt}

Graphical front ends to \textit{APT} (some of these may be in their own package, that must be installed before use). While \texttt{dselect} is arguably the most powerful, it's also the oldest and hardest to use.



\section{Common Dpkg usage}

\paragraph{dpkg -i <package.deb>}

Installs a Debian package file; one that you downloaded manually, for example.

\paragraph{dpkg -c <package.deb>}

Lists the contents of <package.deb>, a .deb file.

\paragraph{dpkg -I <package.deb>}

Extracts package information from <package.deb>, a .deb file.

\paragraph{dpkg -r <package>}

Removes an installed package named <package>

\paragraph{dpkg -P <package>}

Purges an installed package named <package>.  The difference between \textit{remove} and \textit{purge} is that while \textit{remove} only deletes data and executables, \textit{purge} also deletes all configuration files in addition.

\paragraph{dpkg -L <package>}

Gives a listing of all the files installed by <package>.  See also \texttt{dpkg -c} for checking the contents of a .deb file.

\paragraph{dpkg -s <package>}

Shows information on the installed package <package>.  See also \texttt{apt-cache show} for viewing package information in the Debian archive and \texttt{dpkg -I} for viewing package information extracted from a .deb file.

\paragraph{dpkg-reconfigure <package>}

Reconfigures an installed package, if it uses \textit{debconf} (\textit{debconf} provides that consistent configuration interface for package installation).  You can reconfigure \textit{debconf} itself if you want to change the front-end or priority of questions asked. For example, to reconfigure \textit{debconf} with the dialog front-end, you simply run: 
\begin{quote}
dpkg-reconfigure -\/-frontend=dialog debconf
\end{quote}


\paragraph{echo ``<package> hold'' | dpkg -\/-set-selections}

Put <package> on \textit{hold} (command line method)

\paragraph{dpkg -\/-get-selections ``<package>''}

Get the current status of <package> (command line method)

\paragraph{dpkg -S <file>}

Searches for <file> in package database, telling you which installed packages have that file in them. To search for a file or list the contents of a package without installing it, you can use apt-file command line tool.



\section{Building Debian packages from Source}

\paragraph{apt-get source [-b] <package>}

Download the source Debian package for <package> and extract it. You must have deb-src lines in your \textsf{/etc/apt/sources.list} for this to work. If you supply the `-b' option and you are currently root, then the package will be automatically built if possible.

\paragraph{apt-get build-dep <package>}

Download and install the packages necessary to build the source Debian package <package>.  This feature is only present in \texttt{apt} version 0.5 and up.  Currently this means that woody and above contain this functionality.  If you have an older version of \texttt{apt} then the easiest way to find out the build dependencies is to look in the \textsf{debian/control} file in the source package directory.  A common usage of this command is in conjunction with \texttt{apt-get source -b}.  For example (as root): 
\begin{quote}
apt-get build-dep <package> \\ apt-get source -b <package>
\end{quote}
Will download the source package, all of its build dependencies, and attempt to compile the source package.

\paragraph{dpkg-source -x <package.dsc>}

If you have downloaded the source package for a program manually, which includes several files such as a .orig.tar.gz (or .tar.gz if it is Debian native), a .dsc, and a .diff.gz (if it is not Debian native), then you can unpack the source package using this command on the .dsc file.

\paragraph{dpkg-buildpackage}

Builds a Debian package from a Debian source tree.  You must be in the main directory of the source tree for this to work.  Sample usage: 
\begin{quote}
dpkg-buildpackage -rfakeroot -uc -b
\end{quote}
Where `-rfakeroot' instructs it to use the \texttt{fakeroot} program to simulate root privileges (for ownership purposes), `-uc' stands for ``Don't cryptographically sign the changelog'', and `-b' stands for ``Build the binary package only''

\paragraph{debuild}

A handy wrapper script around \texttt{dpkg-buildpackage} that will automatically take care of using \texttt{fakeroot} or not, as well as running \texttt{lintian} and \texttt{gpg} for you. This script is provided by (:program ), so you need to install this package first.



\section{Fixing dependencies}

\paragraph{dpkg -\/-configure -\/-pending}

If dpkg quits with an error while \texttt{apt-get install, upgrade, or dist-upgrade}ing try running this to configure the packages that were already unpacked. Then try \texttt{apt-get install, upgrade, or dist-upgrade -f}, and then try \texttt{apt-get install, upgrade, or dist-upgrade} again. Repeat as needed. This usually resolves most dependency problems (also, if it mentions a specific package for some reason, you might want to try installing or removing that package)

\paragraph{apt-get install -f \\ apt-get upgrade -f \\ apt-get dist-upgrade -f}

Attempt to fix dependencies while doing one of the above. Note that \texttt{apt-get install -f} does not require a <package> argument.



\section{See Also}

\paragraph{man <package>}

To learn more about this commands you can always consult their man pages, e.g. man apt-get, man dpkg. You can also find information about this and more tools, HOWTOs, manuals, etc at http://www.debian.org/doc/.



\end{document}
