I have a relatively grown bash install script I use to install my standard software on fresh debian installations. It mainly consists of apt-get install -f -y lines. I started it in Debain 8 and recently while setting up a Debian 9 i noticed some package names have changed. Is there an efficient way to check all these packages if the package name in my script is still valid or the name has changed? Or do I have to check them all manually?

2 Answers 2


You can use the return code of apt-cache show (assuming you have performed apt update first).

$ apt-cache show curl > /dev/null 2>&1; echo $?
$ apt-cache show foo > /dev/null 2>&1; echo $?
  • Great thanks! Can you explain what the part after show curl > does? Or at least say how this technique is called so I can read about? Commented Nov 2, 2018 at 9:55
  • It is redirecting the command output to /dev/null (the digital black hole). I use 2>&1 because this redirects stderr into stdout. Both of these pipes now write to 'nothing', so you get no output. The semicolon is just a delimiter for the next command. $? is a special variable that stores the return code of the last executed program.
    – Panki
    Commented Nov 2, 2018 at 9:58
  • that's super useful as it works for other commands too (just tried with dpkg-query -s). way better than grepping verbose outputs Commented Sep 16, 2021 at 17:54

If you're on Debian 9 and it has the packages you want, you can dump them using dpkg and ignore your list entirely,

dpkg --get-selections > packages.txt

You can then restore the system to the exact configuration with,

dpkg --set-selections - < packages.txt
apt-get dselect-upgrade

You must log in to answer this question.

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