![]() |
Listing of packages installed on system
Hi,
I know that the command to get the list of all the packages installed on your system is #dpkg -l But the thing is when it shows me the list of packages it marks soem of them 'rc' or 'pi' i.e. means those packages are not there on my system..right? So if those packages are not there why does it still shows them in the list. Is there any command by which I can get only the packages that are installed on my system? Here is the output of the dpkg -l command: Code:
Desired=Unknown/Install/Remove/Purge/Hold |
I've used dpkg --get-selections > selections.txt to output everything installed on my system to a text file.
The thing I like about this command is that I can output it to a text file and then install all the same programs on a different machine with Code:
apt-get update |
Quote:
You gussed it right. I am also trying to do the same i.e. clone the system(atleast the packages). I tried the --get-selections and even in that it showed that some packages have purge/deinstall status. Now why is that? I am really confused here as to what is happening? Why does these command gives list of packages which are purged/uninstalled. Here if the output of my get-selections command: Code:
adduser install |
You know, I think I asked that same question once on the Debian forum here at LQ and didn't get any response. I tried googling the net a bit, but in the end, it was all working right so I didn't bother asking it again.
Maybe it has something to do with how the system has changed from the base install. i.e. if you purged exim from the base system, you want to mark it as purged on the new system also. That was my guess as to what was happening. I bet only packages from a bare bones install are marked that way. Anything else would probably be left off (for example if you installed Battle for Wesnoth, and then purged it, I bet it wouldn't show up on your list at all). Note, I haven't tried this, but it would be pretty easy to install something like that and then --get-selections to one file. Then purge it and --get-selections to another file. Then diff the two files... |
A quick answer to why some packages show "deinstall" or "purge" (I haven't double checked it, it is from memory)
It doesn't matter what it says. If you get-selections on one machine, and you do set-selctions on the other one you'll end up with the same dpkg status. I did this a few times, and nothing to worry about. However, WHEN you do this, make sure you have the same /etc/apt/sources.list on both machines. When you have different versions pointing at in sources.list, you'll end up in chaos. (Not unrecoverable though) jlinkels |
Quote:
Thanks buddy. I second you on that. Thanks for all the help. Atleast I am not the only one who thought like that. :D |
Quote:
Suppose I have a MAchine A on which I do base installation and add some additonal packages. Now I have a machine B on which I would like to install packages of A i.e. Machine B is a clone of MAchine A. But Machine B already has a base-install + it has some other packages like alsa-utils xmms which Machine A does not have. So now I want that all the packages of A are installed on MAchine B and whatever Extra packages machine B has I want to purge/remove them. Will the method that you suggested will work? i.e. If I run the following commands will I be able to achieve what I want i.e. Machine B is a clone of Machine A. Code:
On Machine Athanks in advance. |
My gut feeling is that it will remove all packages that are not set as install (not sure it will purge though). But I guess the only way to find out is to try it (i.e. intentionally install something extra that you know is extra like wesnoth). Then get-selections again to a different file and compare the two files. You should be able to compare relatively quickly.
If I was a scripter, I could probably even figure out an awk string to mark all the packages that don't match as purge. Then you could set-selections with the new file and purge all the extraneous packages... |
Thanks for reply buddy. You seem to know quite a lot of packaging system. Well on some researhing I found out an interesting thing.
If we do #dpkg --get-selections > packages.txt we get list of packages with status install/deinstall but if we do #dpkg --get-selections \* > packages.txt we get list of packages with status install/deinstall/purge How does anyone explain that? What is the difference? What does it signifies? Thanks |
Uhm.. not that I don't want to help anyone, but this comes into an area where thorough reading of the man pages will give you more reliable information that I can give you.
Anyway, your question: Quote:
If you have a list of packages, then Code:
package1 installCode:
package2 deinstallPackages which are not being mentioned in your file will be left alone by dpkg. If you want to deinstall/purge files on machine B in an automated way, you could run --get-selections on both machines and do a diff of the two files. For the files which are present on B and not on A, you could change "install" to "de-install" and run dpkg on B. jlinkels |
OK, i've been trying to follow this up. What i want to do, is a small diskquett which in cludes 2 Sh-Scripts. One to set up APT (its sources) and a second one to insall my personal softwre "minimum". Can you guys help me out? I thought i could just install all the "minimum" stuff i want, and then use the dpkg --get-selections-technique to make a list of the stuff. Whill this work? Thanks
|
In principle, yes. (that is what the thread is about) Your minimum set of packages will be installed.
However, you might need to copy some more files, like /etc/apt/sources.list to make sure you use the same version. Maybe apt-conf as well if you modified it. The same goes for any personal stuff you want to have installed on the other machine, like adapted bashrc or so. jlinkels |
Clean your debian system:
Code:
aptitude purge $(dpkg --get-selections | grep deinstall | awk '{print $1}') |
| All times are GMT -5. The time now is 03:20 PM. |