How can I install some packages temporarily and easily remove them when unwanted several months/years later? The reason for this is that I like to extensively test software before deciding whether to keep it or remove it.

For example, I might install graphic design packages with:

apt-get install inkscape gimp

and mathematics packages with:

apt-get install texlive-full gnuplot

I could use virtual machines for each set of packages (math or design), but it seems like overkill (I do not needed the added security/computational costs).

I could also use apt list --installed and remove the packages I do not need with (for example) apt-get purge texlive-full gnuplot (but this requires me to remember which set of packages I installed - I will always remove the full set at a time and never individual packages in a set).


It depends on what is the reason for "removing" the package/s. You may want: (1) a clean environment, (2) save space (, (3) etc.?)

If you are interested in (1), I list a few alternatives I have used to various degrees (including None):

  1. The Environment Modules package provides for the dynamic modification of a user's environment via modulefiles.
    Modules are useful in managing different versions of applications. Modules can also be bundled into metamodules that will load an entire suite of different applications.
    There are a number of tools based on modules, listed also below.

  2. Flavours is a wrapper built on top of Modules C-version to simplify the organization and presentation of software that requiring multiple builds against different compilers, MPI libraries, processor architectures, etc.

  3. Software Collections is a Red Hat project that enables you to build and concurrently install multiple RPM versions of the same components on your system, without impacting the system versions of the RPM packages installed from your distribution. Once installed a software collection is enabled with the scl command that relies on Modules for the user environment setup.
    Since you mention apt, this may not be useful for you. I googled a little, and it seems to be not available for Debian. https://lists.debian.org/debian-user/2017/02/msg00461.html

  4. The OSCAR Cluster Project uses modules along with a tool called switcher.
    I am not certain what is the current status of development and maintenance. See also https://github.com/oscar-cluster

  5. Flatpak, but as per this I do not know if it is as versatile as Software Collections.

If you are interested in (2), which I guess it not the case since your objection against a VM was it being an overkill and not the space taken, I guess you are bound to install/remove. I do not know of any package that administrates install/remove in package bundles.

| improve this answer | |

apt-get autoremove will remove packages that were installed automatically to satisfy dependencies of another package IF there are no installed packages depending on them.

For example:

# apt-get install inkscape gimp

will install inkscape and gimp and all libraries and other packages that they have listed in a Depends: or Recommends:(*) line.

# apt-get remove inkscape gimp
# apt-get autoremove

will remove both of those packages and all automatically installed dependencies (unless some other package you installed later also depends on them). It will remove ALL auto-installed packages that are no longer needed to satisfy a dependency, not just those automatically installed for inkscape or gimp.

or, to purge them instead of just removing them:

# apt-get purge  inkscape gimp
# apt-get --purge autoremove

If you want to keep a package that was auto-installed, you can use apt-mark to mark it as manually installed. e.g.

# apt-mark manual some-package(s)

You can also mark a package that was manually installed as auto with:

# apt-mark auto some-package(s)

(*) By default, apt will automatically install packages that are listed in either a Depends: line OR a Recommends: line, but auto-installation of Recommended packages can be disabled by setting APT { Install-Recommends "False";}; in /etc/apt/apt.conf or a file in /etc/apt/apt.conf.d/.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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