Install recommended packages of an already installed package with apt

aptsoftware installation

I previously installed a package with the --no-install-recommends and am now missing some functionality due to these packages missing. Is there a way to install these packages with an apt-get command without completely uninstalling it (as this will remove a plethora of dependent packages as well)?

I know I can use apt-cache depends *packagename* | grep Recommends to get a list of these packages, which I can then manually install and manually set to autoinstalled. However I would like to know whether you can do this automatically with apt-get.

Best Answer

With a little bit awk:

apt-cache depends YOUR_PACKAGE | \
    awk '/Recommends:/ {system("sudo apt-get install "$2"; sudo apt-mark auto "$2)}'