PDA

View Full Version : HowTo: Create a list of installed packages



Cynical
September 20th, 2006, 11:28 AM
I found out how to do this recently and thought it might be helpful to some people. To output this information to a file in your home directory you would use,



dpkg --get-selections > installed-software


And if you wanted to use the list to reinstall this software on a fresh ubuntu setup,



dpkg --set-selections < installed-software


followed by



dselect

starscalling
September 21st, 2006, 07:48 AM
bump
damn this is smooth! good looking out!

stalefries
November 6th, 2006, 06:11 AM
Can anyone provide a list generated by this on a clean Edgy install? I'm trying to figure out what I've installed in the past, so I can remove things I no longere need.

xfile087
November 13th, 2006, 03:08 PM
I'm installing Edgy (x86) as we speak so once it's installed I will give you the list!

Included is a list of installed packages on a fresh install.

lo900
November 13th, 2006, 06:45 PM
many thnks

I was looking for this

bierpullen
November 13th, 2006, 07:04 PM
:D I was looking for this:D





------------------------------------------------------
http://www.antarctica-rbak.nl/ubuntu/acer_aspire.php
------------------------------------------------------

Henry Rayker
November 13th, 2006, 07:20 PM
huh. This would be really nice in diagnosing problems I've had.

stalefries
November 14th, 2006, 12:01 AM
Thank you so much!

qamelian
November 14th, 2006, 01:48 AM
You don't need a list of a clean install to get rid of unnecessary packages resulting from installing and uninstalling stuff. Just
sudo apt-get autoremove and apt will generate a list of orphaned packages and give you the option to remove them.

nuclear_eclipse
December 19th, 2006, 07:40 PM
Is there an easy way to tell Ubuntu / dpkg to uninstall every package *except* what's listed in that output file? I'm trying to take an existing install, and remove all the unnecesary packages beyond a basic command line system, but I know of no easy way to do so.

But if I could use a package list from a different system, which is just a command line install, as a basis, and tell it to remove everything but that package list, that would be great.

stijn_pol
January 21st, 2007, 07:39 PM
nuclear_eclipse,
why don't you install Ubuntu server?

jdhore
January 21st, 2007, 08:30 PM
where does the output of the command in the first post (to backup) get put?

lukew
March 5th, 2007, 01:18 PM
where does the output of the command in the first post (to backup) get put?

The directory that you are in. To find this out type (present working directory)


~$ pwd

To put this into a dir called "install" within your home dir you could have

~$ dpkg --get-selections > ~/install/installed-software

ronzo
September 13th, 2007, 11:02 AM
#!/bin/bash

vsave=0
vrestore=0

function usage()
{
echo "USAGE:"
echo "$0 [-s] [-r] [-f installedpackages.txt]"
echo ""
echo "-s ... save installed packages"
echo "-r ... restore installed packages"
echo ""
echo "-f file.txt ... file where installed packages are saved"
echo " or from which installed packages are taken"
echo ""
exit 0;
}

while getopts ":srf:" options
do
case "$options" in
s) vsave=1 ;;
r) vrestore=1 ;;
f) file="$OPTARG" ;;
*) usage;;
esac
done

function doSave()
{
dpkg --get-selections > $file
}

function doRestore()
{
dpkg --set-selections < $file
}

if [ "$vsave" == "1" ] && [ "$vrestore" == "1" ] || [ "$file" == "" ]
then
usage
fi

if [ "$vsave" == "1" ] && [ "$file" != "" ]
then
doSave
fi

if [ "$vrestore" == "1" ] && [ "$file" != "" ]
then
doRestore
fi

chrome307
September 13th, 2007, 03:44 PM
The script didn't work for me (posted above) .... just opened up Archive Manager and that's it.:confused:

capink
September 15th, 2007, 12:08 AM
Is there an easy way to tell Ubuntu / dpkg to uninstall every package *except* what's listed in that output file? I'm trying to take an existing install, and remove all the unnecesary packages beyond a basic command line system, but I know of no easy way to do so.

But if I could use a package list from a different system, which is just a command line install, as a basis, and tell it to remove everything but that package list, that would be great.

Have a look here (http://ubuntuforums.org/showthread.php?t=442974). It might help you.

takuhii
October 19th, 2007, 10:02 AM
Could someone post a CLEAN Gutsy Install list??

inportb
October 25th, 2007, 04:49 AM
This might be helpful if you want to uninstall everything except what's listed in your output file: http://www.inportb.com/wp/index.php/2007/10/24/how-to-save-a-list-of-installed-packages-and-reinstall-the-packages-later/

Evil Dax
October 30th, 2007, 08:02 PM
This is good, it just saved me 1/2 a day of boring work.
Thanks !! :popcorn:

benow
November 12th, 2007, 07:41 PM
cat toremove | xargs --replace=+ sudo apt-get -y remove +

rouge568
March 28th, 2008, 02:57 AM
Thank you very much for this. You have no idea how much time this just saved me.

sigdrifa
March 28th, 2008, 04:44 PM
Great time saver :)
Except one problem for me:
On "dselect" I got "command not found". That was on a fresh Kubuntu Gutsy install.
What worked, however, was to load the file into Synaptic.

whein
April 7th, 2008, 09:39 PM
cat toremove | xargs --replace=+ sudo apt-get -y remove +

Just curious, what does the above code do?
-Will

lennyleonard
April 13th, 2008, 10:03 PM
That's exactly the thing I've been looking for. Thank you very much!

unutbu
April 13th, 2008, 10:25 PM
Just curious, what does the above code do?
-Will



cat toremove | xargs --replace=+ sudo apt-get -y remove +

Short answer:
It removes all packages listed in 'toremove'.

man cat
man xargs
man apt-get


Long answer:
'toremove' is a file with all the packages you wish to remove listed, one package per line. 'cat' lists them all and the pipe '|' pumps the list into 'xargs'. 'xargs' runs 'sudo apt-get -y remove +' where '+' is replaced with the name of a package. 'xargs' runs it once for each package. Cool, eh?

Jad
April 20th, 2008, 07:10 PM
Any idea how to list installed packages from the official ubuntu repository not any other repository, source install or manually downloaded deb package.

unutbu
April 20th, 2008, 10:27 PM
I am not aware of any apt-* or dpkg command that will definitely indicate the repository from which a package came.
I did notice, however, a certain pattern which seems to suggest when a package comes from some source other than an official repo:



17:18:56 cyrano@farmer:~% apt-cache policy acroread
acroread:
Installed: 8.1.2-0medibuntu1
Candidate: 8.1.2-0medibuntu1
Version table:
*** 8.1.2-0medibuntu1 0
100 /var/lib/dpkg/status
17:19:07 cyrano@farmer:~% apt-cache policy gnome-panel
gnome-panel:
Installed: 1:2.20.1-0ubuntu1
Candidate: 1:2.20.1-0ubuntu1
Version table:
*** 1:2.20.1-0ubuntu1 0
500 http://archive.ubuntu.com gutsy-updates/main Packages
100 /var/lib/dpkg/status
1:2.20.0.1-0ubuntu6 0
500 http://archive.ubuntu.com gutsy/main Packages


The packages from the official repos seem to report
http://archive.ubuntu.com while all other packages seem to report /var/lib/dpkg/status.

Based on this pattern, I wrote this perl script which lists packages which are installed on the system grouped according to the repo:


#!/usr/bin/perl
use strict;
use warnings;

my @pkg;
open(PACKAGES,"COLUMNS=500 dpkg -l |") || die;
while (<PACKAGES>) {
if (m/^ii/) {
my ($pkg)=($_=~m/^ii\s+(\S+)\s+/);
push(@pkg,$pkg)
}
}
close(PACKAGES);

my %dat;
foreach my $pkg (@pkg) {
open(APT,"apt-cache policy $pkg |") || die;
my $in_version_section=0;
while (my $line=<APT>) {
if ($line=~m/^\s*Installed: (.*)/) {
($dat{$pkg}->{version})=($line=~m/^\s*Installed: (.*)/);
} elsif ((!$in_version_section)&&(defined($dat{$pkg}->{version})) && ($line=~m/^\s+\S{3}\s+\S+/)) {
my ($a_version)=($line=~m/^\s+\S{3}\s+(\S+)/);
if ($a_version eq $dat{$pkg}->{version}) {
$in_version_section=1;
next;
}
} elsif (($in_version_section) && ($line=~m/^\s+\d+\s+\S+/)) {
($dat{$pkg}->{repo})=($line=~m/^\s+\d+\s+(\S+)/);
last;
}
}
close(APT);
}

my %repo;

foreach my $pkg (keys %dat) {
my $version=$dat{$pkg}->{version};
my $repo=$dat{$pkg}->{repo};
push(@{$repo{$repo}},"$pkg version $version");
}

foreach my $repo (keys %repo) {
print "$repo:\n";
foreach (@{$repo{$repo}}) {
print " $_\n";
}
}

danielv42
May 6th, 2008, 04:33 AM
I wanted a list of packages with their descriptions, so I used:

dpkg -l | grep '^[D|+i]' >> installed_dpkg_l.txt

davidshere
May 12th, 2008, 03:23 PM
Here is a complete list from a fresh minimal Hardy server i386 install:


adduser install
apparmor install
apparmor-utils install
apt install
apt-utils install
aptitude install
at install
base-files install
base-passwd install
bash install
bash-completion install
belocs-locales-bin install
bind9-host install
bsdmainutils install
bsdutils install
busybox-initramfs install
bzip2 install
command-not-found install
command-not-found-data install
console-setup install
console-terminus install
console-tools install
coreutils install
cpio install
cpp install
cpp-4.2 install
cron install
dash install
debconf install
debconf-i18n install
debianutils install
dhcp3-client install
dhcp3-common install
diff install
dmidecode install
dnsutils install
dosfstools install
dpkg install
e2fslibs install
e2fsprogs install
ed install
eject install
ethtool install
fdutils install
file install
findutils install
friendly-recovery install
ftp install
fuse-utils install
gcc-4.2-base install
gettext-base install
gnupg install
gpgv install
grep install
groff-base install
grub install
gzip install
hdparm install
hostname install
ifupdown install
info install
initramfs-tools install
initscripts install
inputattach install
installation-report install
iproute install
iptables install
iputils-arping install
iputils-ping install
iputils-tracepath install
klibc-utils install
klogd install
laptop-detect install
less install
libacl1 install
libatm1 install
libattr1 install
libbind9-30 install
libblkid1 install
libbz2-1.0 install
libc6 install
libc6-i686 install
libcap1 install
libcomerr2 install
libconsole install
libcurl3-gnutls install
libcwidget3 install
libdb4.6 install
libdbus-1-3 install
libdevmapper1.02.1 install
libdns32 install
libedit2 install
libelfg0 install
libexpat1 install
libfribidi0 install
libfuse2 install
libgc1c2 install
libgcc1 install
libgcrypt11 install
libgdbm3 install
libgnutls13 install
libgpg-error0 install
libgpmg1 install
libhtml-parser-perl install
libhtml-tagset-perl install
libhtml-tree-perl install
libidn11 install
libisc32 install
libisccc30 install
libisccfg30 install
libiw29 install
libkeyutils1 install
libklibc install
libkrb53 install
libldap-2.4-2 install
liblocale-gettext-perl install
liblwres30 install
liblzo2-2 install
libmagic1 install
libncurses5 install
libncursesw5 install
libnewt0.52 install
libntfs-3g23 install
libopencdk10 install
libpam-modules install
libpam-runtime install
libpam0g install
libparted1.7-1 install
libpcap0.8 install
libpopt0 install
libreadline5 install
librpc-xml-perl install
libsasl2-2 install
libsasl2-modules install
libselinux1 install
libsepol1 install
libsigc++-2.0-0c2a install
libslang2 install
libsqlite3-0 install
libss2 install
libssl0.9.8 install
libstdc++6 install
libsysfs2 install
libtasn1-3 install
libterm-readkey-perl install
libtext-charwidth-perl install
libtext-iconv-perl install
libtext-wrapi18n-perl install
liburi-perl install
libusb-0.1-4 install
libuuid1 install
libvolume-id0 install
libwrap0 install
libwww-perl install
libxml-parser-perl install
linux-image-2.6.24-16-server install
linux-image-server install
linux-server install
linux-ubuntu-modules-2.6.24-16-server install
locales install
login install
logrotate install
lsb-base install
lsb-release install
lshw install
lsof install
ltrace install
lzma install
makedev install
man-db install
manpages install
mawk install
memtest86+ install
mii-diag install
mime-support install
mktemp install
mlocate install
module-init-tools install
mount install
mtr-tiny install
nano install
ncurses-base install
ncurses-bin install
net-tools install
netbase install
netcat install
netcat-traditional install
ntfs-3g install
ntpdate install
openssh-client install
parted install
passwd install
pciutils install
pcmciautils install
perl install
perl-base install
perl-modules install
popularity-contest install
ppp install
pppconfig install
pppoeconf install
procps install
psmisc install
python install
python-apt install
python-central install
python-gdbm install
python-gnupginterface install
python-minimal install
python-support install
python2.5 install
python2.5-minimal install
readline-common install
reiserfsprogs install
rsync install
sed install
startup-tasks install
strace install
sudo install
sysklogd install
system-services install
sysv-rc install
sysvutils install
tar install
tasksel install
tasksel-data install
tcpd install
tcpdump install
telnet install
time install
tzdata install
ubuntu-keyring install
ubuntu-minimal install
ubuntu-standard install
ucf install
udev install
ufw install
update-inetd install
update-manager-core install
upstart install
upstart-compat-sysv install
upstart-logd install
usbutils install
util-linux install
util-linux-locales install
uuid-runtime install
vim-common install
vim-tiny install
w3m install
wget install
whiptail install
wireless-tools install
wpasupplicant install
xkb-data install
zlib1g install

simon_w
May 20th, 2008, 07:46 AM
Any idea how to list installed packages from the official ubuntu repository not any other repository, source install or manually downloaded deb package.

Appreciate that this is four weeks after your post, but since no-one else has yet made a suggestion, how about temporarily editing your sources.list file to only the official repositories (or whatever you're interested in) and then running:
aptitude search . | grep ^i??

Think that should do it...?

Simon

abhiroopb
June 10th, 2008, 09:13 PM
My question:

I have installed programs through apt, as deb packages and used checkinstall. So all my programs are listed in synaptic and when I create the list using the original command.

However, what I would like to know is when I try to re-install everything will the programs that are NOT in the official repos install? What will happen say for the program avast4workstation? It is listed in the dpkg list but I downloaded it as a separate .deb file from avast.

Thanks in advance!

unutbu
June 10th, 2008, 09:34 PM
I think the reinstall would fail because dpkg would not know where the .deb files are (checkinstall just puts the .debs it creates in the current working directory, no place special where dpkg would find it. `dpkg -i` only installs the deb; it does not copy the deb to /var/cache/apt/archives as far as I know.)

However, I could be wrong, and there is an easy way for you to discover the answer. (Please tell us when you do).

Make a file with contents like this:


avast4workstation install

Save it as "installed-software".
Then run


dpkg --set-selections < installed-software
dselect

abhiroopb
June 10th, 2008, 09:51 PM
Just to test i uninstalled avast, and brasero.

I then added the following to the file "installed-software":



avast4workstation install
brasero install


I then ran dpkg, and dselect (with sudo).

When it opened up the prompt for dselect I choose 3 (install and upgrade wanted packages).

The following was the output (neither brasero NOR avast installed):



abhiroop@Vanimo:~$ sudo dpkg --set-selections < installed-software
abhiroop@Vanimo:~$ sudo dselect
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
nvidia-glx* virtualbox-ose-modules-2.6.22-14-generic*
The following NEW packages will be installed:
brasero
0 upgraded, 1 newly installed, 2 to remove and 0 not upgraded.
Need to get 1363kB of archives.
After unpacking 5181kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com gutsy-backports/main brasero 0.7.1-1~gutsy1 [1363kB]
Fetched 1363kB in 16s (82.8kB/s)
(Reading database ... 134148 files and directories currently installed.)
Removing nvidia-glx ...
Purging configuration files for nvidia-glx ...
dpkg-divert: mismatch on package
when removing `diversion of /usr/lib/libGL.so.1 to /usr/lib/nvidia/libGL.so.1.xlibmesa by nvidia-glx'
found `diversion of /usr/lib/libGL.so.1 to /usr/lib/nvidia/libGL.so.1.xlibmesa by nvidia-glx-new'
dpkg: error processing nvidia-glx (--purge):
subprocess post-removal script returned error exit status 2
Removing virtualbox-ose-modules-2.6.22-14-generic ...
Purging configuration files for virtualbox-ose-modules-2.6.22-14-generic ...
update-rc.d: /etc/init.d/vboxdrv exists during rc.d purge (use -f to force)
dpkg: error processing virtualbox-ose-modules-2.6.22-14-generic (--purge):
subprocess post-removal script returned error exit status 1
Errors were encountered while processing:
nvidia-glx
virtualbox-ose-modules-2.6.22-14-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
Some errors occurred while unpacking. I'm going to configure the
packages that were installed. This may result in duplicate errors
or errors caused by missing dependencies. This is OK, only the errors
above this message are important. Please fix them and run [I]nstall again
Press enter to continue.


It seems nvidia-glx, and virtualbox are giving problems. But I don't know what to do. I use nvidia-glx-new (I think), and NOT the OSE version of virtualbox. Whats happening?

unutbu
June 11th, 2008, 02:22 AM
Let's try to fix things:


sudo apt-get update # update the list of packages available
sudo apt-get -f install # correct broken dependencies

sudo apt-get install nvidia-glx-new # try to reinstall nvidia-glx-new
sudo apt-get install brasero
sudo apt-get purge virtualbox-ose-modules-2.6.22-14-generic

avast4workstation is not in the official repos, so you'll need the deb to reinstall this on.

abhiroopb
June 11th, 2008, 08:02 AM
All that worked, but it didn't take away the problem of using dselect. I think there is stills some prooblem with the two packages. So I deleted them and completely re-installed it all. Now it seems to ok. Anyway I guess to install packages not in repos you can take a look at something I discovered:

http://ubuntuforums.org/showthread.php?t=819396

nooblot
July 6th, 2008, 07:47 PM
how about just "apt-show-versions" ?

jnk0906
July 26th, 2008, 02:17 AM
The output file is formatted with package try per line, so manipulating the file is easy. Once you have the files from the initial and current states, you can run a text-file comparison between the two files to determine which lines are different. Alternately, you can import them into a simply database and run standard SQL queries to identify the new files. If you need to make these changes often then you might want to keep an updated database. SQLite might work well for this as you can store it anywhere. You can simply take the extra package names and append them to the "sudo apt-get remove [packageName1] [packageName2]" command. You may also want to run "sudo apt-get autoremove" afterward to remove the orphans that were previously installed as dependencies.

UPDATE: Sorry, this was in response to post number 10, but that was really old.

xak
October 14th, 2008, 08:26 PM
I've written a small script that I run to record my installed packages. Hopefully someone else will find it useful as well.

It only outputs the core packages, not their dependencies. I believe this is important as dependencies may change between distributions, and you don't want to be installing unnecessary packages.

The script uses deborphan and will automatically install it if you so desire ;-)

Bonus: I have this executing in my ~/.gnomerc file and outputting to a file in my homedir, so I always have an up-to-date list of packages every time my machine boots up. I'd rather have it record them on logout, however I don't want it placed in an init.d script or GDM (I want something user-specific). If anyone else knows how to get gnome to execute a script on logout, please share!

The core command my script uses is:

deborphan --all-packages --no-show-section | egrep --invert-match "linux-.*|.*ubuntu-(server|desktop|minimal|standard)"

The only downfall is it doesn't seem to list packages installed from 3rd party repositories (I have wine installed and it does not output the wine package on my system). Not sure why this is and I'd love to have it show these packages too...

And here is the whole script:

#!/bin/bash
# record manually-installed packages using deborphan
# (will install deborphan using aptitude if not installed)
#
# by Zach [xak .:at:. xak.us]


QUIET=no
if [ "$1" == "-y" ]; then
QUIET=yes
elif [ "$1" == "--help" ]; then
echo "Usage: $0 [-y]"
echo "-y indicates quiet and auto-install deborphan if necessary"
echo ""
echo "Prints installed debian packages, excluding their depenencies and base system packages"
exit -1
fi


if [ `which deborphan >/dev/null 2>&1 ; echo $?` == 0 ]; then
deborphan --all-packages --no-show-section | egrep --invert-match "linux-.*|.*ubuntu-(server|desktop|minimal|standard)"

else
if [ $QUIET == "no" ]; then
echo -n "deborphan not installed. install now? (yes/no) "
read q
fi
if [ $QUIET == "yes" ] || [ "$q" == "y" ] || [ "$q" == "Y" ] || [ "$q" == "yes" ] || [ "$q" == "Yes" ] || [ "$q" == "YES" ]; then
if [ $QUIET == "no" ]; then echo "" && echo "installing..."; fi
sudo aptitude install deborphan >/dev/null 2>&1
if [ $? == 1 ]; then
if [ $QUIET == "no" ]; then echo "install failed!"; fi
exit 2
else
if [ $QUIET == "no" ]; then echo "install succeeded"; fi
$0
fi
else
echo "cannot proceed without deborphan"
exit 1
fi
fi

Cheers!

:guitar:

simon_w
October 15th, 2008, 02:50 AM
Hey xak,

Thanks for the script. However, I think there may be a flaw in the logic here. See below.

First, I think your main command should look like this:


deborphan --all-packages --no-show-section --nice-mode | egrep -v "linux-.*|.*ubuntu-(server|desktop|minimal|standard)" | sort

1) standard practice is to use long-form options in scripts ('cos short-forms may be subject to change in the future)

2) adding --no-show-section removes the need for the pipe to awk (and the sort should go after the awk, but that doesn't matter if you do it this way)

3) you need parentheses "()" not brackets "[]" around 'server|desktop|..." etc. Using brackets in a regexp is interpreted as a character class, with the result that any of the characters inside are matched once and once only (including the pipe). The problem here is that it means that your regexp matches, e.g., 'ubuntu-restricted-extras', which is not a default package and so should not be excluded from this list, if I understand the logic).

try adding --color=auto to see what I mean

deborphan -a | egrep --color=auto ".*ubuntu-[server|desktop|minimal|standard]"

deborphan -a | egrep --color=auto ".*ubuntu-(server|desktop|minimal|standard)"

4) The reason why wine doesn't show up on your list is not because it's from a third-party repository. Deborphan will not report a package if you have another installed which depends on it, but, by default, it will also pass over a package if you have another installed which merely 'suggests' or 'recommends' it. (In the case of wine, it is 'suggested' by gnome-volume-manager. Go figure!). You should disable this feature of deborphan (using --nice-mode).

However, there is still a problem here: circular dependencies. Some packages depend on each other, and will therefore not make it onto this list using deborphan, no matter what you do. A quick example: I mainly use Gnome-based Ubuntu, but I usually install Amarok. The package amarok depends on amarok-xine, and amarok-xine depends on amarok, so it won't appear on this list. Thunderbird is another example from my system.

So although I thinks it's a smart idea to use deborphan in this way, I would urge caution.

Oh - and to execute a script on Gnome logout, call it from /etc/gdm/PostSession/Default.

Hope that helps - thanks for the idea!

Simon

xak
October 15th, 2008, 06:07 AM
1) standard practice is to use long-form options in scripts ('cos short-forms may be subject to change in the future)

2) adding --no-show-section removes the need for the pipe to awk (and the sort should go after the awk, but that doesn't matter if you do it this way)


I agree on long-form parameter names. The sort was to sort the list by package types, not on package names. I am a bit quirky sometimes in how I do things, but this was intentional ;-)


3) you need parentheses "()" not brackets "[]" around 'server|desktop|..." etc. Using brackets in a regexp is interpreted as a character class, with the result that any of the characters inside are matched once and once only (including the pipe). The problem here is that it means that your regexp matches, e.g., 'ubuntu-restricted-extras', which is not a default package and so should not be excluded from this list, if I understand the logic).


Good catch here as well! I will update the script.


4) The reason why wine doesn't show up on your list is not because it's from a third-party repository. Deborphan will not report a package if you have another installed which depends on it, but, by default, it will also pass over a package if you have another installed which merely 'suggests' or 'recommends' it. (In the case of wine, it is 'suggested' by gnome-volume-manager. Go figure!). You should disable this feature of deborphan (using --nice-mode).

However, there is still a problem here: circular dependencies. Some packages depend on each other, and will therefore not make it onto this list using deborphan, no matter what you do. A quick example: I mainly use Gnome-based Ubuntu, but I usually install Amarok. The package amarok depends on amarok-xine, and amarok-xine depends on amarok, so it won't appear on this list. Thunderbird is another example from my system.

So although I thinks it's a smart idea to use deborphan in this way, I would urge caution.


Well this just means my goal is set back a little. There must be a way to accomplish creating this list of packages. Any other ideas? Do you think the best way might be to diff the full installed-package list against a default distro package installation list? What about dependencies?



Oh - and to execute a script on Gnome logout, call it from /etc/gdm/PostSession/Default.


I'm aware of this as well, but I wanted a user-specific way of accomplishing this, like ~/.gnomerc, without modifying the system. The best ideas I have come up with so far are a script launched by .gnomerc or a session which waits for the gnome processes to die (very ugly approach), or sourcing a user's file such as ~/.gnome-logout from PostSession/Default (but this requires system modification).


Thanks a bunch for your comments and suggestions!

dazzlindonna
November 2nd, 2008, 02:16 PM
Quick newb question: When I run the first command, it creates the nice list, but next to each item is either the word "install" or a few say "deinstall". Why would a few of them say "deinstall"?

unutbu
November 2nd, 2008, 03:13 PM
The packages that say "deinstall" are those that were installed on your system at one point, but have since been removed.

rylangrayston
November 11th, 2008, 03:41 PM
thanks this is great
very smooth

loomsen
November 23rd, 2008, 01:08 AM
I agree on long-form parameter names. The sort was to sort the list by package types, not on package names. I am a bit quirky sometimes in how I do things, but this was intentional ;-)


##### SNIP ####
Thanks a bunch for your comments and suggestions!

OK, I gotta admit I only stumbled upon this thread and read a few keywords which made me think... You might want to take a look at
www.instalinux.com

It will generate a minimal installation image of a distro you'd like, basically a netinst.

I made a debian as well as a Intrepid for myself, and I have to say this is exactly what I've been looking for ever since. A basic yet minimalistic gnome-desktop, almost any apps were installed(no evolution, no firefox, no instant-messenger, basically really nothing)

The other way round compared to deborphan, but at least as much fun (in fact, it's even more fun than continuosly uninstalling pkges, imho)

Anyway, so, if you have the feeling your dist is getting somewhat bloated again, this way at least it was your fault :D

No, honestly, give it a try, it's great, I always wondered why ubuntu wouldn't provide sth like that. Even the debian netinstaller is too bloated imho, 135mb one could as get from the internet.

However, takes bout 2 mins to make your selection, and another minute to create your 10MB sized iso.

Have fun.


2nd)

Script to be run at shutdown:

Either you could make it a PostSession Script, here:

docter[~] locate Post | grep -i sessi
/etc/gdm/PostSession
/etc/gdm/PostSession/Default


Or, what I prefer, have a crontab doin it.


man cron

for crontab reference.

CoolDreamZ
February 14th, 2009, 10:21 AM
Very useful, thanks! If you want to see what versions of the packages you have installed try:


dpkg-query -l

simon_w
February 14th, 2009, 01:07 PM
@loomsen - I very much share your sentiment, I like to do things this way too. I prefer to build up from the minimal CD though https://help.ubuntu.com/community/Installation/MinimalCD, and install packages myself from there.

ruru
March 14th, 2009, 03:00 PM
Is there also a neat trick to dump a list of repositories and reload this in a fresh install? I use several 3rd-party repos so reinstalling my package list will throw errors...

unutbu
March 14th, 2009, 03:23 PM
ruru, if you save your /etc/apt directory to a USB flash drive, then do a fresh install, then copy the /etc/apt directory from the flash drive to the root partition of the fresh install, then you should be good to go.

Edit: You may need to open a terminal (Applications>Accessories>Terminal) and run


sudo apt-get update
to make the fresh install aware of the packages available).

ugm6hr
March 14th, 2009, 03:26 PM
ruru, if you save your /etc/apt directory to a USB flash drive, then do a fresh install, then copy the /etc/apt directory from the flash drive to the root partition of the fresh install, then you should be good to go.

Or even just your /etc/apt/sources.list file.

If you upgrade, you will obviously have to change all hardy references to intrepid etc.

unutbu
March 14th, 2009, 03:31 PM
ugm6hr, yes you are probably right :)

However, depending on the way the third-party repos are enabled, the necessary files might be located in /etc/apt/sources.list.d, rather than in sources.list. And then there are also the GPG keys stored in /etc/apt/trustdb.gpg... So, I figured what the heck, just save the entire /etc/apt directory ... :)

ugm6hr
March 14th, 2009, 03:37 PM
And then there are also the GPG keys stored in /etc/apt/trustdb.gpg... So, I figured what the heck, just save the entire /etc/apt directory ... :)

Good point.

I'd forgotten that.

ruru
March 14th, 2009, 03:48 PM
I had just saved /etc/apt/sources.list and was going to post this, but the point about the keys hadn't occurred to me either - so thanks for that!

cirorodrigues
March 24th, 2009, 06:00 PM
Hi. Two questions:
1) Does it work if any of applications was installed from a deb package downloaded directly to disk?
2) Do I need to setup any alternative repository before try reinstall ?

anyway, that's indeed a very interesting hack. Thanks.

cirorodrigues
March 24th, 2009, 06:17 PM
forget about this. I didn't read all the posts before this one...

noukist
March 26th, 2009, 11:39 AM
thanks man ;)

:fish: :fish:

loomsen
March 27th, 2009, 02:11 PM
And then there are also the GPG keys stored in /etc/apt/trustdb.gpg.

Actually, you should save your keyring rather than the database, due to the same reason your sources.list gets updatet with a new release.

Your reimportable keyring is

/etc/apt/trusted.gpg


apt-key add <path-to-backed-up>/trusted.gpg


and you're fine after a new release or whatever.

You could make a symlink for instance so you won't miss is when backin up...



@simon: me too in the meanwhile. Bootstrapping from a running system into a chroot is very nice too imho.

mfyahya
June 15th, 2009, 04:21 AM
This bash snippet will download the .deb package files for all installed packages on your system. Useful if you've deleted them from /var/cache/apt/archives/ with `apt-get clean` and if you want the package files for any reason.



dpkg --get-selections | awk '{ print $1};' | while read package; do apt-cache show "$package"| wget -c 'http://ae.archive.ubuntu.com/ubuntu/'`sed -ne '/^Filename/s/^Filename: //p'`; done

cw8jw
August 19th, 2009, 05:08 PM
Can this be done to show installed version levels, instead of just package names?

Thanx!

unutbu
August 19th, 2009, 05:22 PM
cw8jw, open a terminal (Applications>Accessories>Terminal) and type

aptitude -F '%?p %?V' search '~i'

You'll see output like this:


a2ps 1:4.14-1
acl 2.2.47-2
acpi 1.1-1ubuntu1
acpi-support 0.114-0intrepid2
...

fallingleaf
October 14th, 2009, 11:09 PM
I used this method to transfer all my installed apps over when I did a clean install of Karmic. The problem is that it also installs all the old kernels you might have installed and other system stuff that might not be compatible. The worst thing was that it installed grub 1 and uninstalled grub 2 so that a later kernel update failed because it was trying to update menu.lst which no longer exists in grub 2. It would be nice if there were an easy way to just reinstall apps and leave system stuff alone.

davidshere
December 3rd, 2009, 04:07 PM
Great time saver :)
Except one problem for me:
On "dselect" I got "command not found".
Same problem here on fresh install of 8.04.2. Instead, run:

david@bearcat:~$ sudo dselect
and you'll get:

The program 'dselect' is currently not installed. You can install it by typing:
sudo apt-get install dselect
So type that and you'll get

david@bearcat:~$ sudo apt-get install dselect
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
dselect
0 upgraded, 1 newly installed, 0 to remove and 236 not upgraded.
Need to get 405kB of archives.
After this operation, 2228kB of additional disk space will be used.
Get:1 http://.... hardy-updates/main dselect 1.14.16.6ubuntu4 [405kB]
Fetched 405kB in 3s (133kB/s)
(Reading database ... 95977 files and directories currently installed.)
Unpacking dselect (from .../dselect_1.14.16.6ubuntu4_i386.deb) ...
Setting up dselect (1.14.16.6ubuntu4) ...

The Real Dave
December 20th, 2009, 05:12 PM
Thank you OP! :D

bobarry
February 14th, 2010, 08:49 PM
I found out how to do this recently and thought it might be helpful to some people. To output this information to a file in your home directory you would use,



dpkg --get-selections > installed-software


And if you wanted to use the list to reinstall this software on a fresh ubuntu setup,



dpkg --set-selections < installed-software


followed by



dselect

Great trick. However I did it recently and I had to add the dselect program before it would work. It now has some options to pick from, but the default works fine.
You have to use sudo dselect.

Many Thanks
Bo Barry

Redsandro
April 30th, 2010, 02:00 PM
What do you need dselect for? According to this (http://savvyadmin.com/backup-and-restore-package-lists-in-ubuntu/), you can just type:
sudo dpkg install

eroeurbano
June 5th, 2010, 04:48 PM
Hi all,
I've installed Ubuntu 10.04 on two machine (work and home).
I finally could get to solve an issue I had with migrating
a drupal website by installing a few packages related to
php apache2 and mysql, on my home computer.

I now would like to get a list of the packages I've installed
related to these three softwares and install them also on my work
computer to install them and finally fix the problem there as well.

I'm very new to Ubuntu so I don't know if this an easy or silly task
(if so I'm sorry for the question).

Thanks to all in advance,
Cheers -Luca

cmcanulty
June 7th, 2010, 04:59 PM
dpkg --get-selections > installed-software
gives me nothing and I did run deselect first

Axilus
June 19th, 2010, 05:10 PM
After accidentally nuking my laptop this thread has been very helpful.

cmcanulty
June 19th, 2010, 05:15 PM
I thought mine was not working at all, not knowing that it doesn't show up in terminal but as a text file in your home folder.

JoelKrause
June 20th, 2010, 02:04 PM
This is really cool. Thanks.

kdford
July 14th, 2010, 02:34 AM
I know this is OLD, but can't you just sort the KNOWN fresh install package list, plus your package list (that has all your installed packages), and remove from your list of all installed packages, those that are IN the fresh install package list? That would leave you with the list of packages your CURRENT installation has, that are NOT part of the base install. You can then pipe that file into -remove or -purge. In theory it will work.

I started messing around with it, and thought of using sort and uniq but one issue with that is that if you have REMOVED a package that was in the fresh install, it could end up in your remove_these_packages.txt file. So.. If you had something like this...



ini-list.txt
packageA
packageB
packageD
packageC

cur-list.txt
packageB
packageD
packageC
packageE
package22

You could prefix them, using sed, so that they look like this

sed 's/^/cur-list-/' cur-list.txt
sed 's/^/ini-list-/' ini-list.txt

ini-list.txt
ini-list-packageA
ini-list-packageB
ini-list-packageD
ini-list-packageC

cur-list.txt
cur-list-packageB
cur-list-packageD
cur-list-packageC
cur-list-packageE
cur-list-package22Then, you could simply combine them together, like...


cat ini-list.txt cur-list.txt > ful-list.txtand use uniq with the -u switch to show only things that are NOT duplicated, like this...


uniq -u -s 9 ful-list.txt > difference_packages.txt(the -s 9 option tells uniq to IGNORE the first 9 characters when testing for uniqueness. This is necessary because you want to compare package names, but you have prefixed your package lines with text that you will later use to determine the origin of the package). This will remove all packages that you CURRENTLY have that are also in the initial (fresh) install. It will also leave you with packages that are in the fresh install that you do NOT have (if any)... Because you added the prefixes, you can now simply grep the file twice, once looking for cur-list- and again looking for ini-list-, and pipe the grep results into awk to remove the prefix. Then you will have two files, one is the packages you need to remove, the other is the packages that you need to install (if any)

You can remove these prefixes in a number of ways but sed would do the trick, like this...



cat difference_packages.txt | grep ini-list- | sed '9s/^.//' > to_install.txt
cat difference_packages.txt | grep cur-list- | sed '9s/^.//' > to_delete.txt
I have not tested any of that code, it is just from memory but you can work out the kinks if nicessary, I'm sure.

Hope that helps/makes sense.

Kevin

Redsandro
July 22nd, 2010, 04:34 PM
I haven't checked it but it sounds awesome. You are pretty terminal savvy. It would be greatly appreciated if you can put that in a script that makes the list.

cmuxed
August 3rd, 2010, 01:13 PM
This is great for when your system is running, however what if you don't have an up to date list of the installed applications on a system that has crashed beyond [my ability to] repair? I can access the file system drive of my old system but cannot boot it, does anyone know how I can get a list of the applications I had installed on that machine? Where is this information stored... some file or db somewhere?

Redsandro
August 3rd, 2010, 03:26 PM
[..] but can't you just sort the KNOWN fresh install package list [..]

Does anyone know where one would get a list of initial packages kdford calls ini-list.txt in the example, without reinstalling Ubuntu? Is it specified somewhere?

-edit-

@cmuxed

I'm not sure, but have you tried looking in
/var/lib/apt/lists/
and
/var/lib/dpkg/status

If you find the best reference of a list on a broken system, let us know. :)

cmuxed
August 5th, 2010, 08:42 AM
Ill take a look. Thanks

cmuxed
August 5th, 2010, 09:01 AM
@Redsandro,

I took a look in the /var/lib/apt/lists/ as you suggested and there are a lot of text files there what looks to be tracking the changes made with apt, lots of info! More than I need at this point in time but useful nevertheless, so I ran the following command to get a list just of their package names:

@%mypc%:~$ cat /media/%mounteddisk%/var/lib/apt/lists/*Packages* | grep "Package:" > /home/%myusername%/Desktop/oldpackages.txt

I got a nice list of all the packages I had installed!! Awesome. Thanks for the suggestion.

Redsandro
August 5th, 2010, 12:00 PM
Note that I don't exactly know what's in there, so maybe those packages that are downloaded but not installed or waiting to be removed are also mentioned in there.

I think the second 'link' has more info about installed or not, but it has a lot of other information you don't need so it would need some grepping through the data.

If the information you acquired from /var/lib/apt/lists/ is correct, I'm glad I could help nonetheless. :) Thanks for the command line. Let me quote it for future reference, might come in handy. :)

cat /media/%mounteddisk%/var/lib/apt/lists/*Packages* | grep "Package:" > /home/%myusername%/Desktop/oldpackages.txt

cmuxed
August 6th, 2010, 10:00 AM
@Redsandro


maybe those packages that are downloaded but not installed or waiting to be removed are also mentioned in there.

Yeah, you are right, the second 'link' does include the status of each package; installed or removed etc. I have modified my command to slightly increase the verbosity of the grep filter, which suits my cause for now. I don't intend to re-bloat my new installation with all the apps I had shoved into the old box, so will use this data as a guide and format as necessary.

Code as follows will show all packages installed or removed:


cat /media/%mounteddisk%/var/lib/apt/lists/*Packages* | grep -A 1 "Package:" > /home/%myusername%/Desktop/AllOldpackages.txtCode for just the installed packages:


cat /media/%mounteddisk%/var/lib/apt/lists/*Packages* | grep -B 1 "Status: install ok installed" > /home/%myusername%/Desktop/OldInstalledPackages.txtObviously don't use my crap file names!

Cheers

Redsandro
August 6th, 2010, 01:39 PM
@Redsandro

cat /media/%mounteddisk%/var/lib/apt/lists/*Packages* | grep -B 1 "Status: install ok installed" > /home/%myusername%/Desktop/OldInstalledPackages.txtObviously don't use my crap file names!

Cheers

So easy? :o

When I had to do something similar on some text, I actually wrote a PHP script to do regular expressions because apparently there was a flaw in my logic. :p

Thanks.

cmuxed
August 8th, 2010, 04:00 AM
@Redsandro

No probs mate. Thanks again for the lead, hopefully others will find this useful too. :D

borislavsabev
August 12th, 2010, 11:02 AM
I was looking for this!Thanks.

purplegirl5
August 12th, 2010, 12:40 PM
Just what I needed. Thanks.;)

cry8wolf9
September 8th, 2010, 10:13 PM
ok im trying to use a list i made to reinstall a bunch of packages but every time i use

dpkg --set-selections < ubuntu-files
i get this error


dpkg: operation requires read/write access to dpkg status area


also note it is not a fresh install i just want to reinstall some things

fallingleaf
September 8th, 2010, 10:41 PM
ok im trying to use a list i made to reinstall a bunch of packages but every time i use

dpkg --set-selections < ubuntu-files
i get this error


dpkg: operation requires read/write access to dpkg status area


also note it is not a fresh install i just want to reinstall some things

Need sudo for that command.

cry8wolf9
September 8th, 2010, 10:52 PM
ok that didnt do what i wanted is there a command that reinstalls already installed packages?

ramnarayan
November 19th, 2010, 08:10 AM
Thanks

was looking for this to migrate from 9.10 to 10.10
had such a smooth stable system that am reluctant to move but feel the Ubuntu fever for a new version :-)

ram

Redsandro
January 1st, 2011, 03:03 PM
Just as a note,

Some distro's cannot automatically get dselect (like Lubuntu)

apt-get install dselect
package dselect not found

You can download the .deb package from here:
http://packages.debian.org/sid/dselect

Scroll down and pick the right platform. Get a link and you can simply do e.g.:

wget http://ftp.de.debian.org/debian/pool/main/d/dpkg/dselect_1.15.8.7_i386.deb
dpkg -i dselect_1.15.8.7_i386.deb

(all as root)

sajansen
February 13th, 2011, 04:56 PM
i was wondering is tare a command that lists all installed packages except the standard ubuntu stuff?

cmcanulty
February 13th, 2011, 06:20 PM
http://www.ubuntugeek.com/create-backup-of-all-installed-packages-using-aptoncd-in-ubuntu.html
http://www.ubuntugeek.com/howto-reinstall-all-of-currently-installed-packages-in-fresh-ubuntu-install.html
http://www.arsgeek.com/2006/09/19/ubuntu-tricks-how-to-generate-a-list-of-installed-packages-and-use-it-to-reinstall-packages/
http://www.unixtutorial.org/2008/09/list-installed-packages-on-your-ubuntu-linux/

BHEJU
March 14th, 2011, 08:48 PM
Great tip.
Big Thanks to OP.

Cheers,

stchman
March 16th, 2011, 10:10 PM
You can also use the following command:



sudo dpkg -l > <file_name>

LeeU
July 27th, 2011, 01:46 AM
Thanks, danielv42 for the extra details! Fantastic!

Redsandro
July 27th, 2011, 07:00 AM
Thanks, danielv42 for the extra details! Fantastic!

lol nobody knows what you're talking about, I am guessing this quote from 2008:

I wanted a list of packages with their descriptions, so I used:

dpkg -l | grep '^[D|+i]' >> installed_dpkg_l.txt

Anyway, nowdays you can import/export your package selection or custom selections from synaptic. :) (Without descriptions though.)

cmcanulty
July 27th, 2011, 01:31 PM
In synaptic click file-save marking and be sure save full state is checked name file and it is in your home folder. To reinstall all just click in synaptic file-read markings.

Redsandro
July 27th, 2011, 02:13 PM
Yep, that's kind of what I meant. :)

j*tech
September 6th, 2011, 06:06 PM
How can I direct the output to my flash USB?

kdford
September 6th, 2011, 06:34 PM
How can I direct the output to my flash USB?

dpkg -l | grep '^[D|+i]' >> /media/SOME-USB_DRIVE/installed_dpkg_l.txt

j*tech
September 6th, 2011, 09:05 PM
Thnx

dcsoldschool53
September 7th, 2011, 02:37 PM
it still works like a charm, Thank you.

meowsus
September 20th, 2011, 01:58 AM
dpkg --get-selections > installed-software

This command will produce *all* packages currently on the system, which includes packages that were installed and then removed. For a clean list of packages installed on the system in it's current state, run:


dpkg --get-selections | grep -v deinstall > installed-software

madtom1999
October 10th, 2011, 11:30 AM
Over time I get a lot of unused packages accumulation.
Can one use popularity-contest to generate a list of recently used packages so I can do a fresh install/upgrade and then load what I use and then restore /home etc?

Todamont
December 13th, 2011, 02:59 AM
Great comment. I will install ALL the things! Muahaha!!!

Redsandro
December 13th, 2011, 03:22 AM
FTFY

http://weknowmemes.com/wp-content/gallery/x-all-the-things/x-all-the-things-template.jpg

InonS
January 2nd, 2012, 01:03 PM
I wasn't interested in listing all of the dependencies, but just the top packages, for which all the others would be installed automatically.
Here's my script:




dpkg --get-selections > installed-software
touch top_dependents # create file to list top dependents
while read PAK # read installed-software file, line-by-line
do
if [ "$(apt-cache rdepends $PAK | tail -1)" != "Reverse Depends:" ] # is the reverse depends (i.e. dependents) list empty? (can also be implemented using sed instead of tail)
then echo "$PAK has dependents" # user feedback. can be commented out
else
echo "$PAK is top dependent" # user feedback. can be commented out
echo $PAK >> top_dependents # append to top dependents list
fi
done < installed-software


Hope others make use of this. Feel free to tweak!

condos2012
January 2nd, 2012, 02:40 PM
wow, thanks for the script. it's very useful

InonS
January 2nd, 2012, 08:38 PM
CAUTION: If I have a package A installed which has some other package B dependent on it, but I did not install package B, the script might not show A as a top package (since the repositories will have package B listed as dependent on A). This means that the output of my script will not include any such package as A, and there may be MANY such packages.

Can anyone offer a way to have the script go only over packages installed localy, rather than checking dependencies on the repository?


I wasn't interested in listing all of the dependencies, but just the top packages, for which all the others would be installed automatically.
Here's my script:




dpkg --get-selections > installed-software
touch top_dependents # create file to list top dependents
while read PAK # read installed-software file, line-by-line
do
if [ "$(apt-cache rdepends $PAK | tail -1)" != "Reverse Depends:" ] # is the reverse depends (i.e. dependents) list empty? (can also be implemented using sed instead of tail)
then echo "$PAK has dependents" # user feedback. can be commented out
else
echo "$PAK is top dependent" # user feedback. can be commented out
echo $PAK >> top_dependents # append to top dependents list
fi
done < installed-software


Hope others make use of this. Feel free to tweak!

InonS
January 8th, 2012, 06:25 PM
Fixed: add " --installed " after the apt-cache command to limit the search to packages currently installed (as opposed to packages which exist in the repos but are not currently installed).


CAUTION: If I have a package A installed which has some other package B dependent on it, but I did not install package B, the script might not show A as a top package (since the repositories will have package B listed as dependent on A). This means that the output of my script will not include any such package as A, and there may be MANY such packages.

Can anyone offer a way to have the script go only over packages installed localy, rather than checking dependencies on the repository?

evil gnome
February 24th, 2012, 10:21 PM
I have a list of packages that I want to remove. what is the command to remove all packages within a text list?

oldfred
February 25th, 2012, 12:31 AM
this is a way to install:

cat list-of-packages.txt | xargs sudo apt-get install -y
cat package-list': you're printing the contents of the file package-list to the standard output
' | ': this is a pipe, it sends the standard output from the previous command to the standard input of the next.
'xargs sudo apt-get install ': xargs takes the standard input, and adds it on to the following command (sudo apt-get install) as arguments.

If you change install to remove or purge it should work. Have not tried it. See also:
man apt-get

Bas Roufs
June 4th, 2012, 12:31 PM
You can reach this article also via this short address:
http://tinyurl.com/8yjrfpf

How to create a list of installed packages - revision 2012.


(...)
dpkg --get-selections > installed-software
(...)

And if you wanted to use the list to reinstall this software on a fresh ubuntu setup (...)

dpkg --set-selections < installed-software

followed by
(...)
dselect


Thank you, Cynical :), for your advise written in 2006. Recently, I tried this out with Kubuntu 12.04 LTS. Now, in 2012, your approach still works quite well: also for *Ubuntu 12.04 LTS.;) However, a few details are slightly different -eg. the package dpkg only works now with super user privilege. That's why I summarise here how I do it today.

Start at the PC which has a *Ubuntu configuration you like. Open a terminal there and give in the following command:



sudo dpkg --get-selections > installed-software

..for generating a list of packages at an existing system.

Than, copy the list to the home directory at another configuration: the same computer after a fresh install or another computer at which you want to copy the configuration of the PC where you have generated the list.

There, open a terminal at the PC where you want to install the packages from the list. First install the package "dselect" if it's not already there:



sudo apt-get install dselect.


Stay in the terminal and give in the following command:



sudo dpkg --set-selections < installed-software


Then, stay in the same command line and give in this command:



sudo dselect


And choose for option 3: "install and upgrade wanted software".
It might take a few hours before all the packages will be installed - however, everything will work automatically from this point on.

Finally, I share with you a few points of attention.

In my opinion, this method is only safe when working with the same version of the same distro at the "old" and "new"configuration: eg. from Kubuntu 12.04 LTS to Kubuntu 12.04 LTS.

However, it is an excellent method to save a lot of time in case you want exactly the same software configuration in a fresh install at the same or another computer. Eg. at my main computer, I upgraded from Kubuntu 11.10 to 12.04 about one month ago. However, the system symply did not work smoothly - it kept crashing several times per day. So,I backed up my data to an external HD and my software configuration to the file "installed-packages". Afterwords, I carried out a fresh install of the same distro and version at the main computer. Via "installed-packages"I regenerated the configuration I want. Now, everything seems to work well again :p.

In case you would like to start working with a next version of your distro, act as follows:
1. backup all your data;
2. upgrade the existing configuration;
3. generate a.s.a.p. the list of installed packages and backup also that file at a external HD.
3. use this list in case of a fresh install.
About two times per year I carry out a fresh install at both of my computers - with a view to maintaining a well-functioning configuration.

If you want "ttf-mscorefonts-installer": install it first via a graphical package manager.
A nasty detail is the package "ttf-mscorefonts-installer": the package for "microsoft" fonts like Verdana, Arial, etc. If you want this in your system, install it via graphical package manager - only in this way you can indicate accepting the conditions you need to accept in order to be able to install it. !! Please do so before working with the list of installed packages - as summarised above!! Otherwise, the installation process will stagnate somewhere half way. If this happens, give in the following command:


sudo apt-get purge ttf-mscorefonts-installer

After doing so, the installation process will resume and smoothly come to an end. :p. Then, go to your graphical package manager: Muon, Synaptic or whatever. From there, install again ttf-mscorefonts-installer.

More than 1 system language?
Another point of attention is relevant in case you have more then 1 "system language" in your system: Dutch, French, Spanish, Italian, Russian or whatever. They do come back in a new system configuration in case they are at the list of installed packages.However, you need to check whether spell checkers for those .languages are present in packages like Firefox, KMail and Libre Office. If so, perfect! :-) If not, act as follows:
+ go to SYSTEM SETTINGS > locale > system languages > tab "uninstall".
+ leave the first system language, UNinstall each other language;
+ then go to the tab "install" and (re)install from there each language you want in your system.

This it it for now :lolflag:... I hope it benefits someone.
Respectfully yours,
Bas Roufs.

ray30
June 4th, 2012, 11:36 PM
:guitar: Hey there I read you post and I am new at this and want to
know how I create a script, I am runnin K10.10mm?

rayy

Bas Roufs
September 23rd, 2012, 04:10 PM
Now, in 2012, I still use this very useful approach to backup a list of installed packages.


I found out how to do this recently and thought it might be helpful to some people. To output this information to a file in your home directory you would use,



dpkg --get-selections > installed-software


And if you wanted to use the list to reinstall this software on a fresh ubuntu setup,



dpkg --set-selections < installed-software


followed by



dselect


UPDATE. There is one important difference: it is only possible to carry out the commands as superuser.
So open a terminal and give in the following command:


sudo dpkg --get-selections > installed-software


By doing so, you will get list of installed packages in the HOME directory, with the name "installed-software". Backup this file to an external hard disk, to another computer, etc. It is this file you neeed to use at another computer or at the same one after a fresh install of the same distro and version.

After the fresh install, copy the file "installed-software" to the HOME directory of the new configuration. A next step is the installation of the package "dselect": that one will not be installed by default along with a fresh install. For this purpose, open a terminal and give in the following:


sudo apt-get install dselect


For getting your favourite software after the fresh install, also use a terminal, with the following command:



sudo dpkg --set-selections < installed-software


followed by



sudo dselect


As I said before, you can do so with a view to installing the same packages after a fresh install of the same distro and version: either at the same computer or at another one. !!! If you want to create a similar configuration after an upgrade, act as follows:
first upgrade;
than carry out the instructions summarised here.
Why: during each upgrade, several packages will be obsolete, added, removed, etc.

Respectfully yours,
Bas Roufs.

Redsandro
September 24th, 2012, 09:19 AM
Here's another one. To get all packages that were installed by the user without descriptions and other markings, use


aptitude search '!~M ~i' -F '%p'.
Save them to a file:

aptitude search '!~M ~i' -F '%p' > packages.txt.

You can simply apt-get install the list next time you install Ubuntu.

Bas Roufs
October 23rd, 2012, 01:17 PM
Now, in 2012, I still use this very useful approach to backup a list of installed packages.....

Shortcut to this page:
http://bit.ly/OYQsls

vasa1
October 23rd, 2012, 01:24 PM
Shortcut to this page:
http://bit.ly/OYQsls
You could just provide the full url since there is no limitation in forums.

GrayBear
May 10th, 2013, 08:36 AM
Much better than "--get-selections", you can create a list of all installed packages, along with package version and short description:


dpkg -l > packages.2013-05-10


replace "2013-05-10" with today's date so in time you can check which versions were installed each time you issued the above command line.

cmcanulty
May 10th, 2013, 01:31 PM
Gray Bear How do you use your file to reinstall them?

stuartbh
May 27th, 2013, 03:25 PM
I just installed 13.04 and I had a package list of add-ons that I created and it got deleted (though all the packages were installed prior). What I'd like to do is figure out how to get a list of all packages that I added.

Is there a place I can get a list of default installed packages for 13.04 (I saw people post them for other releases of Ubuntu)?

Someone said to use the following to determine what packages were added post install, but it had things on the list like "gzip" which I know I did not install post-install and were installed as part of the installation, so something is wrong with this output.

aptitude search '!~M ~i' -F '%p'


Stuart

vasa1
May 27th, 2013, 03:55 PM
...
Is there a place I can get a list of default installed packages for 13.04...?
...
See if http://packages.ubuntu.com/raring/ubuntu-desktop helps.

Also look through /var/log/apt/history.log for more. After a while the older logs will be compressed. But you can copy them over to your home folder and uncompress them.

stuartbh
May 27th, 2013, 05:08 PM
Vasa1,

Thank you so very much, your suggestion of looking in history.log is most helpful!!! I figured there had to be an apt-get install log somewhere, you saved me hunting it down.

I also resolved to do another install of ubuntu-gnome into a virtual machine, will update it, and then take a dpkg --get-selections > installed-software to find out what it put there to start with.


Stuart

Redsandro
November 5th, 2013, 03:58 PM
Is there a way to get the list of installed packages, EXCLUDING the dependencies? Like only the main apps and tools?

It would be convenient for looking through the list and making changes. Otherwise you have a thousand dependency packages with which you don't know what do to.

ibjsb4
November 5th, 2013, 04:12 PM
All your GUI packages should be located in:

/usr/share/applications

Redsandro
November 5th, 2013, 04:18 PM
Thanks. but I don't mean only GUI. Those are the easiest to remember.

During the course of a year you find a lot convenient applications, and you use them in your workflow, batch scripts, builds etc.
For example, image magick, doxygen, pandoc, different video tools.

I usually go through my list of packages to see if I can leave things out, but it's so annoying to go through a list of two thousand packages when it could be a list of two hundred applications. I'm probably exaggerating here.

But there are 'father' packages, on which nothing depends. Obviously, in theory it's possible to find out which they are. I am looking for such a way. :)

oldfred
November 5th, 2013, 05:25 PM
With aptitude you can get top level only. But not for reinstall directly.

Top level only - no depends (not for reinstall)
sudo apt-get install aptitude
aptitude --disable-columns -F '%p' search '~i!~M!~R(~i)' > toplevel
or
aptitude search '?installed ?not(?reverse-depends(?installed))'

Alternative way with aptitude:
aptitude --display-format '%p' search '?installed!?automatic' > ~/my-packages
sudo xargs aptitude --schedule-only install < my-packages
sudo aptitude install

Top level applications:
aptitude --disable-columns -F 'no_dependents %p' search '~i!~M!~R(~i)'
sudo aptitude --disable-columns -F '%p' search '~i!~M!~R(~i)' >toplevelonly
aptitude --disable-columns -F 'no_dependents %p' search '~i!~M!~R(~i)'

Redsandro
November 5th, 2013, 06:21 PM
This is golden:

aptitude --disable-columns -F '%p' search '~i!~M!~R(~i)'
Thank you.

But what do you mean by this?
no depends (not for reinstall)

Depends will automatically be installed, or the top level package won't be installed. Maybe this would actually be a safer way to reinstall those packages otherwise you might install dependency libraries and older libraries that were dependencies for an older version (when one generated the list).

oldfred
November 5th, 2013, 08:00 PM
It just is a list without depends, but the list itself cannot directly be used to reinstall just the top level apps. Yes depends will then correctly be included.
I have seen some posts on using grep to parse a file to get just the needed file list in the proper format for dpkg to reinstall, but did not save it.
It looks like it just is the app, and you need the second parameter if using dpkg.

Merrattic
November 6th, 2013, 01:45 AM
I find this works for me

cat /var/log/dpkg.log | grep " \install\ "



and see here: http://ubuntuforums.org/showthread.php?t=1952639

Redsandro
November 6th, 2013, 02:38 PM
the list itself cannot directly be used to reinstall just the top level apps.

If you mean the newlines, it's rather trivial. This will work:

sudo apt-get install `cat packages.toplevel.list | tr '\n' ' '`

Cynical
March 4th, 2014, 03:44 AM
I had created this thread a long time ago and basically forgot about it, which is why I hadn't replied to any of the questions here. I'm kind of amazed it grew so large and is still useful to people. It makes me very happy to read through all the comments about how it saved people half a days work. Anyway I was a far less experienced Linux user during that time so I didn't think to mention any caveats about using sudo or that it copies all packages, I was just excited to find something that worked for me. Cheers all.

vasa1
March 4th, 2014, 04:40 AM
I had created this thread a long time ago and basically forgot about it, which is why I hadn't replied to any of the questions here. I'm kind of amazed it grew so large and is still useful to people. It makes me very happy to read through all the comments about how it saved people half a days work. Anyway I was a far less experienced Linux user during that time so I didn't think to mention any caveats about using sudo or that it copies all packages, I was just excited to find something that worked for me. Cheers all.
And thank you for "bumping" it. I had forgotten all about it but will now bookmark it very securely :)

Muhammad_Ahmad_Mujtaba
April 19th, 2014, 10:36 AM
hello this thread is good but perhaps not so good for me!
I have created installed-software but when i try to install them on fresh ubuntu 14.04 alot of dpkg-errors happen!
for example:
dpkg: warning: package not in database at line 1638: xtrans-dev
dpkg: warning: package not in database at line 1652: zlib1g:i386
dpkg: warning: package not in database at line 1652: zlib1g-dev:amd64

how to resolve this?

oldfred
April 19th, 2014, 03:20 PM
@Muhammad_Ahmad_Mujtaba
How old was old install? Often a few packages are not in new version, or you may have had old packages not marked obsolete in your old install.

You will have to research each package. I would copy an paste into synaptic as it often has a bit more info.
sudo apt-get install synaptic

In synaptic in my 12.04 I do see xtrans-dev as a package, but not currently running 14.04 to check there.

vasa1
April 19th, 2014, 03:50 PM
...
In synaptic in my 12.04 I do see xtrans-dev as a package, but not currently running 14.04 to check there.
Re. 14.04:
[08:18 PM] ~ $ apt-cache policy xtrans-dev
xtrans-dev:
Installed: (none)
Candidate: 1.3.2-1
Version table:
1.3.2-1 0
500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
[08:19 PM] ~ $