How do I upgrade a single Debian package without marking it as "manually installed"? apt install upgradeable-lib works of course, but then I have to apt-mark auto (or the package is no longer autoremoveable).


4 Answers 4


By poking at the sources, I found the feature you are looking for, but it was made available only in a commit made a few months ago, so is available only in bullseye (future Debian 11):

Support marking all newly installed packages as automatically installed

Add option '--mark-auto' to 'apt install' that marks all newly installed packages as automatically installed.

The equivalent configuration option (having no effect in Debian 10) is APT::Get::Mark-Auto.

  • 3
    This probably won't hurt anything, but it could mark some packages as automatic when they are new installs and "should" be marked as manual.
    – Joe
    Aug 16, 2020 at 21:20

Since I got tired of copy/pasting, I've ended up writing aptup to do the simple job of upgrading specified packages (or choosing from a list of upgradables via dialog). apt-mark showauto pkg... prints the automatically-installed status, which can be restored after apt-install.

  • Great tool, thanks for sharing!
    – pfalcon
    Apr 1, 2021 at 17:05
  • 1
    thanks -- which reminds me, I need to update the link. Not sure how long gitlab auto-redirects last
    – usretc
    Apr 1, 2021 at 21:11

I ran into this awhile ago trying to install everything from an old install onto a new one using a package list provided by running dpkg -l on the old system.

This is handy if you want everything you had before, but can't remember all the things you installed over the life of the installed system.

The following script does this by trying to install everything using the install_new function. The trick is to run dpkg -s package-name first. If it doesn't find the package, it returns an error so you know the package is not installed.

The script below has a echo prefixed on the apt command, so it will be a dry run until you remove the prefix. This will allow you to review what it will do first so you can edit the input list and eliminate things you don't want to carry over to the new system or redirect the output of the script into a file to run later to do the installs. This is particularly useful because some "reinstalls" may fail, so you may need to fix things and edit the file to restart where you left off.

To use the script to generate an installation script, the other echo commands in the script need to be commented out.


function install_new () {
  if [[ -z "$1" ]]
    echo "install_new called with empty argument"
    dpkg -s "$1" &> /dev/null
    if (( rc ))
      echo sudo apt-get install "$1"
      echo -e "\tSkipping [$1] - already installed"
  return ${rc}

while read package action
  echo "Package [${package}] Action [${action}]"
  action="${action:-install}"  ## If action is not present, default to install
  case "${action}" in
      install_new "${package}"
      echo -e "\tDon't know how to ${action} ${package}"  

done < "${1}"
  • So this keeps the manually installed status as opposed to using dpkg --get-selections then set-selections
    – usretc
    Aug 17, 2020 at 20:47
  • @AldIn Not sure what you mean. If you manually install a package, it makes sense for it to be marked manual, as my script will do, but since it would be unlikely to have another package that depends on it, it probably won't make any practical difference. What the script does is prevent already installed packages from being set to manual if they were automatic.
    – Joe
    Aug 19, 2020 at 6:09
  • "prevent already installed packages from being set to manual if they were automatic" is what I meant. Because there is no "upgrade only specified packages" semantic in Debian (seems to be a unique deficiency) so you have use apt install
    – usretc
    Aug 21, 2020 at 22:38

You can't in apt, but the interactive mode of aptitude can do this.

I question why you want to do it though. Automatically-installed libraries are installed because something you've expressed a desire to install needs the library to function. By asking apt to install a different version of the library, you're expressing a desire to install it. It's no longer automatic - you have asked for it and apt will no longer consider it removable when dependent packages go away.

  • Because somepkg might depend, directly or indirectly, on somelib. apt install somepkg will upgrade somepkg, but not necessarily somelib. apt install somelib will upgrade both the lib and all packages that break with the new lib version
    – usretc
    Aug 8, 2020 at 17:01
  • 2
    Can you expand on how one would do it with aptitude?
    – Quasímodo
    Aug 8, 2020 at 17:14
  • Aptitude was great, but it seems not so well maintained lately, and has always been quite opinionated. Plus, it's not available on Termux
    – usretc
    Aug 8, 2020 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .