Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In an attempt to learn more about Ubuntu and its packages, I want to remove all non-essential packages, so I can install what I need, when I need them and know what they do.

I'm using the commands dpkg --clear-selections and apt-get dselect-upgrade for this. I also slightly modify the selection by setting apt libstdc++6 (due to apt) install-info (due to grep) to install again (somehow dpkg thinks they are not essential, but apt-get complains).

Is this ok, or is this bad? If it's ok, what do I do with the large list of packages with "deinstall" status in dpkg?

An additional note, I'm doing this on a VPS template so I have no control over the initially installed packages.

share|improve this question
up vote 13 down vote accepted

With the following command you can obtain a list of installed packages, classified by priority:

dpkg-query -Wf '${Package;-40}${Priority}\n' | sort -b -k2,2 -k1,1

A description of priorities is given in the Debian Policy Manual.

In my installation I obtain the following (I only show required, important and standard packages):

apt                                     important
aptitude                                important
apt-utils                               important
bsdmainutils                            important
cron                                    important
debconf-i18n                            important
dmidecode                               important
gnupg                                   important
gpgv                                    important
groff-base                              important
info                                    important
install-info                            important
iptables                                important
iputils-ping                            important
isc-dhcp-client                         important
isc-dhcp-common                         important
libapt-inst1.3                          important
libapt-pkg4.11                          important
libboost-iostreams1.46.1                important
libcwidget3                             important
libept1                                 important
libgdbm3                                important
libgdbm3                                important
libgudev-1.0-0                          important
libnewt0.52                             important
libpcre3                                important
libpipeline1                            important
libpopt0                                important
libreadline6                            important
libssl1.0.0                             important
libsysfs2                               important
libusb-0.1-4                            important
libxapian22                             important
logrotate                               important
man-db                                  important
manpages                                important
medibuntu-keyring                       important
nano                                    important
netbase                                 important
net-tools                               important
python                                  important
readline-common                         important
rsyslog                                 important
ubuntu-extras-keyring                   important
ubuntu-keyring                          important
vim-common                              important
vim-tiny                                important
wget                                    important
whiptail                                important
adduser                                 required
base-files                              required
base-passwd                             required
bash                                    required
bsdutils                                required
busybox-initramfs                       required
coreutils                               required
cpio                                    required
dash                                    required
debconf                                 required
debianutils                             required
diffutils                               required
dpkg                                    required
e2fslibs                                required
e2fsprogs                               required
findutils                               required
gcc-4.6-base                            required
gcc-4.6-base                            required
grep                                    required
gzip                                    required
hostname                                required
ifupdown                                required
initscripts                             required
insserv                                 required
iproute                                 required
klibc-utils                             required
libacl1                                 required
libacl1                                 required
libattr1                                required
libattr1                                required
libblkid1                               required
libbz2-1.0                              required
libc6                                   required
libc6                                   required
libc-bin                                required
libcomerr2                              required
libcomerr2                              required
libdb5.1                                required
libdbus-1-3                             required
libdevmapper1.02.1                      required
libdrm2                                 required
libdrm-intel1                           required
libdrm-nouveau1a                        required
libdrm-radeon1                          required
libffi6                                 required
libgcc1                                 required
libgcc1                                 required
libglib2.0-0                            required
libklibc                                required
liblocale-gettext-perl                  required
liblzma2                                required
libmount1                               required
libncurses5                             required
libncursesw5                            required
libnih1                                 required
libnih-dbus1                            required
libpam0g                                required
libpam-modules                          required
libpam-modules-bin                      required
libpam-runtime                          required
libpciaccess0                           required
libpcre3                                required
libplymouth2                            required
libpng12-0                              required
libselinux1                             required
libselinux1                             required
libslang2                               required
libss2                                  required
libssl1.0.0                             required
libstdc++6                              required
libstdc++6                              required
libtext-charwidth-perl                  required
libtext-iconv-perl                      required
libtext-wrapi18n-perl                   required
libtinfo5                               required
libudev0                                required
libuuid1                                required
libuuid1                                required
locales                                 required
login                                   required
lsb-base                                required
lzma                                    required
makedev                                 required
mawk                                    required
module-init-tools                       required
mount                                   required
mountall                                required
multiarch-support                       required
ncurses-base                            required
ncurses-bin                             required
passwd                                  required
perl-base                               required
plymouth                                required
procps                                  required
python2.7-minimal                       required
python-minimal                          required
sed                                     required
sensible-utils                          required
sysvinit-utils                          required
sysv-rc                                 required
tar                                     required
tzdata                                  required
udev                                    required
upstart                                 required
ureadahead                              required
util-linux                              required
xz-utils                                required
zlib1g                                  required
zlib1g                                  required
at                                      standard
bash-completion                         standard
bc                                      standard
bind9-host                              standard
dc                                      standard
dnsutils                                standard
file                                    standard
ftp                                     standard
gettext-base                            standard
less                                    standard
libbind9-60                             standard
libcap2                                 standard
libdb5.1                                standard
libdns69                                standard
libedit2                                standard
libevent-2.0-5                          standard
libgc1c2                                standard
libgcrypt11                             standard
libgcrypt11                             standard
libgnutls26                             standard
libgnutls26                             standard
libgpg-error0                           standard
libgpg-error0                           standard
libgpm2                                 standard
libgssapi-krb5-2                        standard
libgssapi-krb5-2                        standard
libidn11                                standard
libidn11                                standard
libisc62                                standard
libk5crypto3                            standard
libk5crypto3                            standard
libkeyutils1                            standard
libkeyutils1                            standard
libkrb5-3                               standard
libkrb5-3                               standard
libkrb5support0                         standard
libkrb5support0                         standard
libldap-2.4-2                           standard
libldap-2.4-2                           standard
liblockfile1                            standard
liblwres60                              standard
libmagic1                               standard
libpci3                                 standard
libsasl2-2                              standard
libsasl2-2                              standard
libsqlite3-0                            standard
libsqlite3-0                            standard
libtasn1-3                              standard
libtasn1-3                              standard
libxml2                                 standard
lsof                                    standard
m4                                      standard
make                                    standard
mime-support                            standard
mlocate                                 standard
openssh-client                          standard
patch                                   standard
pciutils                                standard
perl                                    standard
perl-modules                            standard
python-apt                              standard
python-central                          standard
telnet                                  standard
time                                    standard
ucf                                     standard
wamerican                               standard
whois                                   standard

The Base System is defined as a system containing only required and important packages.

Packages marked as standard are not strictly needed for a working system, but you can get into difficulties if you miss them.

So, to remove all unneeded packages (optional and extra), you can execute the following command:

sudo apt-get --simulate purge $(dpkg-query -Wf '${Package;-40}${Priority}\n' | 
    awk '$2 ~ /optional|extra/ { print $1 }')

I added the --simulate option to be safe and see what apt says.

Strangely, it asks to remove also some required packages: e2fsprogs, util-linux, hostname and upstart, so it is necessary to reinstall these packages. I would download the packages in advance (apt-get download <packages>), to avoid network problems after.

Take also into account that for a working Wifi you can need some optional or extra package, removed in the above procedure.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.