Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-15-2009, 09:42 AM   #1
Registered: Jul 2009
Location: Slovakia
Posts: 141

Rep: Reputation: 16
apt vs aptitude little tutorial

Hi all I dont know if this is right place but I saw somewhere dd tutorial so I decidet to write a little tutorial about debian package manager. I hope this will clear some misundersands about it, maybe somewher i will be wrong or somebody could explain it better so any comments are welcomed.
Many users in ubuntu/debian use just apt-get install packagename but dont know that package commands can do a much more.
First off all must say that debian/ubuntu use more package managers apt-*, aptitude, GUI add/remove, synaptic ... Is good habit to choose one of them, apt-get or aptitude. Aptitude and apt-get use different kind of treating package dependencies (will be discused later). Ubuntu GUI applications are just wrappers on apt-get NOT aptitude.

Lets celar some terms:
Package: It is a special kind of archive which contains data (binary - desired software, source code, configuration files...)
Repository: In ubuntu/debian world packages stored on internet are organized in repositories. Repository is simply a database of packages that can be downloaded and installed from internet.
Database: Every package managers (apt-*, aptitude) use its own database for storing informations about installed, purged (removed) packages. This is because you should choose one package manager (apt-* or aptitude) so your database will be consistent.
Dependencies: In linux world one aplication can be used by other aplication, for example alsa (sound card utility) is used also with mplayer (movie player) which must play sound in movies and totem (music player) for playing music.
Similar situation is in packages one package can be usesd with another, and that is depenndency.

There are two dependencies:
Reverse Dependencies: are those packages which are dependent on our package (our package must be installed when we want install one of those packages)
Classical dependencies: are those packages which on are our package depend (those packages must be installed when we want install our package)
For example lets say we have package firefox
Reverse Dependencies are firefox plugins, themes ...
Classical Dependencies are those packages which firefox need to run.

I think only way that aptitude differ from apt- is that aptitude stores in his package database markauto and unmarkauto information.
Unmarkaouto are those packages that user installed himself. Markauto are those which were installed autimaticaly causing dependencies.

There is also dpkg command which I mostly use to manage *.deb packages. Note that all package commands require sudo privileges.

We can divide managing packages by localization of packages into these 3 sections:
manage installed packages
manage non installed (from internet) packages
manage non installed (*.deb) packages

Q: how to find from which package is ls command
A: dpkg -S /bin/dd; OR dpkg -S `which ls`;

Q: How to find all packages in system ?
A: dpkg -l \*; show more packages not just installed, the lines begin with
ii - installed, rc - reconfigured, pi - pre installation finished, un - uninstalled, pn, d. I must say that i google somewhere and man dpkg did not gives me
the infomration about that , so if somebody know more about it comments are welcomed. so command: dpkg -l; shows all installed packages (those which begin with ii).
Also you can use command: aptitude search '~i'; which output: i - packages installed by user and A - automaticaly installed packages for dependencies.

Q: What version of package i have installed ?
A: dpkg -s packagename | grep Version

Q: How to find all files from installed package
A: dpkg -L packagename

Q: How to remove installed package?
A: There are more posibilities: apt-get remove packagename; OR dpkg --remove packagename (BUT THIS LAS ONE DID NOT WORK FOR ME). This command removes package and keep configuration files
if you want remove also configuration files try this: apt-get --purge remove packagename OR aptitude remove packagename. In this way aptitude and apt differs, if you remove package with aptitude it automaticaly remove dependencies
with apt you must specify it explicitly. I dont know if is possible to preserve dependencies with aptitude, so if somebody please comment.

Q: how to upgrade to newest version of instaleld package ?
A: apt-get upgrade packagename OR aptitude upgrade packagename.

Q: where are stored logs for aptitude and dpkg ?
A: /var/log/aptitude, /var/log/dpkg.log. If i am right apt did not have log.

Q: how to tell aptitude and apt-get which repository to use ?
A: that can be done editing /etc/apt/sources.list after this you must issue command: apt-get update; OR aptitude update; which synchronize informations (packages names, size, versions...) from internet repositories with our database managed by apt OR aptitude.

Q: how to find packagename ?
A: apt-cache search -n sniffer; will indd those packages which contains in his name word sniffer. command: apt-cache search sniffer; will find those which have sniffer in name OR description.

Q: how to find version, dependencies, size, installed size and some other info about package avalible in repository?
A: apt-cache search -nf packagename OR apt-cache show packagename. I dont know about aptitude equivalent so if you please comment.

Q: how to find dependencies in repository package (very similar to previous command but list only dependencies)
A: apt-cache showpkg packagename OR aptitude show packagename

Q: How to install pacakge from repositories
A: apt-get install packagename OR aptitude install packagename if you want just simulate installation apt-get -s install packagename OR aptitude -s install packagename

Q: how to download package from repositories
A: apt-get -d install packagename OR aptitude -d install packagename. *.deb package will by stored in /var/cache/apt/archives

Q: how to install package which need dependencies ?
A: This is very magican command, if you cannot install something try this first: apt-get -f install OR aptitude -f install. It should repair dependencies problems and you could install package which need other packages.

Q: how to list all packages avalible in repo ?
A: apt-cache pkgnames; OR apt-cache search .; (dot included) OR apt-get install (tab, tab). I dont know exactly which is correct.

Q: where are stored *.deb archives after i issue apt-get install packagename; OR aptitude install packagename;
A: they are strored in /var/cache/apt/archives/ you can delete them by usinh classic method rm OR issuing commands: apt-get clean; OR aptitude clean;

Q: how can i install *.deb package(s) stored in hard disk?
A: dpkg -i packagename; OR if you want install multiple packages: dpkg -R /directory/name;

Q: how to display contents of *.deb ?
A: dpkg -c packagename.deb OR dpkg-deb -c packagename.deb display content in ls -l format.

Q: how to display dependencies, size, installed size, description.... of *.deb archive ?
A: dpkg-deb -I packagename.deb OR dpkg -I packagename.deb

So if i compare apt vs aptitude:
aptitude automaticaly purge configuration files if package is uninstalled, apt- must use --purge option unless it preserve configuration files.
aptitude use markauto and unmarkauto information about package.
apt-get (NOT aptitude) is used by GUI based aplications in ubuntu. (if you use them you should use apt NOT aptitude)
aptitude stores logs in /var/log/aptitude apt not.
aptitude IS NOT front end of apt-
apt IS NOT front end of aptitude
You should use one apt or aptitude NOT BOTH.

My personal questions to gurus:
What is dpkg --get-selections > bak; dpkg --set-selections < bak; (just another format for dpkg -l) ?
which commands do you mostly use ?
Which to use list all repositories packages. apt-cache pkgnames; OR apt-cache search .; (dot included) OR apt-get install (tab, tab);
what is aptitude equivalent for apt-cache search -nf packagename OR apt-cache show packagename.
What is and why did not work for me: dpkg --remove packagename
what is dpkg --remove packagename ? IT DID NOT WORK FOR ME

I hope this would be useful for somebody who use aptitude or apt and want to try other. If you read to the end congratulations

Old 08-15-2009, 10:01 AM   #2
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
I'm not sure this is ready from prime time yet. I've noticed one error and there may well be some others.
Q: how to upgrade to newest version of instaleld package ?
A: apt-get upgrade packagename OR aptitude upgrade packagename.
This is not correct, at least not on my version of aptitude which is running on Debian/Sqeeze.
#aptitude upgrade kdm
W: The "upgrade" command is deprecated; use "safe-upgrade" instead.
E: The upgrade command takes no arguments
#aptitude safe-upgrade kdm
E: The safe-upgrade command takes no arguments
The way to upgrade an installed package to the latest version is to use the "install" option.
#aptitude install kdm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
apt-get vs. aptitude freddie_leaf Debian 28 01-13-2011 06:56 AM
[SOLVED] apt-get and aptitude riganta Linux - Desktop 8 03-06-2009 04:07 PM
aptitude and apt-get (again) DavidMcCann Debian 10 02-03-2009 06:06 PM
aptitude vs apt-get PCalitrack Ubuntu 3 08-08-2006 11:34 AM
aptitude .vs. apt-get thelonius Debian 12 07-25-2006 10:52 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration