LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 08-09-2009, 07:50 AM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

Rep: Reputation: 19
list packages


I am new at Ubuntu and learning to use apt. It seems that packages are marked in a number of ways, and I can't follow this easily. Can anyone please clarify what do these commands actually list:

Code:
dpkg --get-selections | wc -l
318
dpkg -l | wc -l
323
dpkg -l \* | wc -l
852
apt-cache search . | wc -l
25211
apt-cache pkgnames | wc -l
32633
dpkg -l lists 5 header lines, so it corresponds to dpkg --get-selections, both list installed packages.
dpkg -l \* also lists some not installed packages, but less than apt-cache search ..
apt-cache search . lists all installed and available packages?
apt-cache pkgnames apparently includes older versions packages in its list.

Also, please tell me if apt-get is functionally equivalent to aptitude? I mean, anything done easily in command line with aptitude can also be done easily with apt-get and its apt-* companions?

Thank you for your time.

Last edited by doru; 08-09-2009 at 10:18 AM.
 
Old 08-11-2009, 06:16 AM   #2
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
The --get-selections option for dpkg, according to "man dpkg" is:
Quote:
--get-selections [package-name-pattern...]
Get list of package selections, and write it to stdout. Without
a pattern, packages marked with state purge will not be shown.
For searching for packages, I like to use aptitude instead of dpkg or apt-cache. To search for a package with aptitude, just run:
Code:
aptitude search package_name
If you don't know the exact name of the package, it will list anything that matches the search term. For example, try running:
aptitude search java
and it will list all the packages with java in their names.
An "i" before the package means that it is installed. And an "A" after the "i" means that the package was automatically installed (for example, as a dependency). A "p" before a package means it is purged (i.e., not installed).

To get more info about a specific package, use:
aptitude show package_name
and you will get detailed info about that package.

The apt-get and aptitude commands differ in how they handle dependencies. Suppose package A has as it's dependencies packages B, C, and D. Both apt-get and aptitude will install the dependencies. But if you remove package A with apt-get, it will leave dependencies B, C, and D on your system, unless you use the --purge option with apt-get.
Aptitude will remove dependencies B, C, and D, as long as they are not needed by other packages.
Keep in mind that synaptic, Add / Remove, and update manager in Ubuntu are GUI front ends for apt-get, not aptitude.
Here is an excellent tutorial on aptitude:
http://algebraicthunk.net/~dburrows/.../rn01re01.html
You should not mix apt-get and aptitude. Be consistent. For best results, wither use apt-get exclusively or aptitude exclusively.

Aptitude is the recommended package manager now in Debian. For Ubuntu though, I would recommend that you use apt-get to be consistent with update manager. If you do not use update manager, synaptic, or Add / Remove, and if you do all updates and package management from the terminal, then it is your choice whether to use apt-get or aptitude.

Last edited by tommcd; 08-11-2009 at 06:39 AM.
 
Old 08-11-2009, 10:05 AM   #3
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

Original Poster
Rep: Reputation: 19
tommcd: Thank you for your answer. It helps me find my way around.

I have a big problem with aptitude, which refuses to search anything but shorthands.
Code:
aptitude search "?name(apt)"
gives:
Code:
E: Regex compilation error: Invalid preceding regular expression
while
Code:
aptitude search ~napt
works well. I just installed Ubuntu server and have no idea what is wrong.

I believe that aptitude should also be a front-end for apt-get. I believe that apt-get and aptitude should work together well, because the tutorial that you mention says that reinstalled packages will not be recorded as reinstalled, because apt-* utilities can not record that information (see http://algebraicthunk.net/~dburrows/...h02s02s03.html). Also, apt-get and aptitude use the same cache. Still, it is wise to be cautious.

aptitude is slower than apt, but it offers very advanced search and info features. I believe that aptitude builds some dependency graph, on every call.

apt-get autoremove removes automatically installed dependencies. apt-get --purge-unused should do the same.

After all this reading, I still have no idea what could be the difference between
Code:
dpkg -l | wc -l
323
and 
dpkg -l \* | wc -l
852
Sure the number of available packages in Ubuntu is bigger than 852.

Thanks for your answer!

Last edited by doru; 08-11-2009 at 10:11 AM. Reason: format and better English
 
Old 08-12-2009, 04:43 AM   #4
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
Quote:
Originally Posted by doru View Post
I have a big problem with aptitude, which refuses to search anything but shorthands.
The "?" and "~" are wild cards when searching with aptitude. I use them this way (using java as an example):
Code:
aptitude search java?
Are you unable to use aptitude to search without the wild cards? What happens if you just run:
Code:
aptitude search java
You should get a list of all the java packages.
Quote:
Originally Posted by doru View Post
I believe that aptitude should also be a front-end for apt-get. I believe that apt-get and aptitude should work together well...
Aptitude is not a front end for apt-get. They are similar, but they do handle dependencies slightly differently. I don't see any reason to use both apt-get and aptitude for installing and removing packages. On the other hand, I have experimented in Debian with both apt-get and aptitude to see how each command handles installing and removing packages. I never had a problem switching between apt-get and aptitude. If you hang out in the Debian forums, you will find that many long time Debian users use apt-get; while many others use aptitude. Some say apt-get is better; and some say aptitude is better. The one thing they all seem to agree on though, is that you should pick one or the other and stick with it. If you have been using aptitude and want to switch back to apt-get, I have read that it is a good idea to first run:
Code:
aptitude keep-all
to cancel any pending actions that aptitude may have set.
BTW, that tutorial I linked to is essentially the same as "man aptitude".
Quote:
Originally Posted by doru View Post
After all this reading, I still have no idea what could be the difference between
Code:
dpkg -l | wc -l
323
and 
dpkg -l \* | wc -l
852
Sure the number of available packages in Ubuntu is bigger than 852.
The dpkg -l lists installed packages. The pipe into wc -l just counts the number of lines in the output, which is the same as the number of installed packages.
For what it's worth, here is what I get when I run:
Code:
dpkg -l | wc -l
1276
and:
Code:
dpkg -l \* | wc -l
3107
I guess the reason I get more packages is because I have a full Ubuntu install, while you have the server version. I do not know what the \* is supposed to do with the dpkg command. Do you know?
Just out of curiosity, what are you trying to learn from using these 2 dpkg commands?

Last edited by tommcd; 08-12-2009 at 04:50 AM.
 
Old 08-12-2009, 05:22 AM   #5
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by tommcd View Post
The "?" and "~" are wild cards when searching with aptitude. I use them this way (using java as an example):
Code:
aptitude search java?
~ and ? are escape characters in aptitude, they introduce search patterns. There is no point in adding ? there.

Quote:
Originally Posted by tommcd View Post
Aptitude is not a front end for apt-get. [...]
Thanks for the great info.

Quote:
Originally Posted by tommcd View Post
The dpkg -l lists installed packages. The pipe into wc -l just counts the number of lines in the output, which is the same as the number of installed packages.
For what it's worth, here is what I get when I run:
Code:
dpkg -l | wc -l
1276
and:
Code:
dpkg -l \* | wc -l
3107
I guess the reason I get more packages is because I have a full Ubuntu install, while you have the server version. I do not know what the \* is supposed to do with the dpkg command. Do you know?
Just out of curiosity, what are you trying to learn from using these 2 dpkg commands?
I started with Ubuntu one week ago. First priority, after basic config, was how to manage packages. Examples on the net used apt-get, so I went into it. I needed to get a list of installed packages on my system, one on a line, for grep and future reference. The solution seemed to be dpkg -l, as apt-cache was overdoing it. That's how I got here. apt-cache show . shows many more packages then dpkg -l \*, and apt-cache pkgnames even more packages. I thought that, if I understand which are the differences between these commands, I will understand better the package management system in Ubuntu.

My system uses apt-get for regular upgrades, and it came with aptitude preinstalled.

apt-get man: "Several "front-end" interfaces exist, such as dselect(8), aptitude, synaptic, gnome-apt and wajig."

Last edited by doru; 01-25-2010 at 03:26 AM. Reason: completion
 
  


Reply

Tags
apt-get, aptitude, list, package



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
how to save a list of installed packages and install these packages later mandavi Ubuntu 5 09-07-2009 11:36 AM
Problem with packages - local list doesn't list all packages from a mirror simopal6 Debian 2 09-01-2008 04:44 AM
List of packages gloomz Debian 11 02-02-2007 11:06 AM
get list of latest list of packages bobwall Linux - Distributions 1 11-30-2004 03:48 PM
A list of RedHat packages? rkfb Linux - Newbie 1 10-21-2003 04:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 09:16 AM.

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