UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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?
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.
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
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
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
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?
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
Aptitude is not a front end for apt-get. [...]
Thanks for the great info.
Quote:
Originally Posted by tommcd
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.