33

I'm trying to create a minimalist debian install for my netbook. I have a clonezilla restore point that I made right after a fresh minimal debian install.

I do not have any packages other than what debian installs automatically during a minimal install. I deselected everything in taskel (no desktop environment, nothing).

I want to install some packages. Since I am creating a minimalist install, I want to always use sudo apt-get --no-install-recommends <package-name>.

Is there a way that I can create like a custom abbreviated command for this? Or is there a way that I could copy and paste a bunch of those commands into a text document and then run them all sequentially using one command? Do you know of a simpler, more elegant way to accomplish running a bunch of packages installs from a freshly installed minimal command prompt?

Jonas Schäfer
  • 1,422
  • 11
  • 24
Chuck
  • 331
  • 1
  • 3
  • 3
  • Related: [How to not install recommended and suggested packages?](https://askubuntu.com/q/179060/78223) – kenorb May 08 '19 at 11:13

2 Answers2

59

You can configure apt via apt.conf files.

Here is a command I use on my server (as root):

cat > /etc/apt/apt.conf.d/01norecommend << EOF
APT::Install-Recommends "0";
APT::Install-Suggests "0";
EOF

To see if apt reads this, enter this in command line (as root or regular user):

apt-config dump | grep Recommends
esplor
  • 691
  • 4
  • 3
  • 4
    If `apt-config dump` says your line is ignored, it could be because another file in this directory (find it with `grep`), say `99synaptic`, overrides it, in which case you'll want to edit that file, or rename 01norecommend by increasing the leading number so it is read later. – Marc Glisse Jan 21 '14 at 07:31
  • 1
    And after I added the configuration for not installing recommended packages, is there a way to change this setting for one run of apt-get install? – andrybak Mar 26 '15 at 21:30
  • 1
    `--install-recommends` - just like you could go one step further and also `--install-suggests` which is already off by default – Ryan Pavlik Feb 22 '16 at 18:52
  • Using a separate file is a good suggestion as it makes it MUCH easier to remove the file at the end of a bootstrap since many applications actually have a tighter dependency on packages that they "recommend" that would be more akin to "depends" but maybe is only required if using the app via GUI or something so it isn't strictly necessary 100% of the time. – dragon788 Nov 02 '20 at 03:43
4

Here is a one-liner to create /etc/apt/apt.conf.d/999norecommend file as per @esplor's answer:

apt-config dump | grep -we Recommends -e Suggests | sed s/1/0/ | sudo tee /etc/apt/apt.conf.d/999norecommend
kenorb
  • 24,736
  • 27
  • 129
  • 199
  • `sed` fails in my distro, as the current value is `true`, not `1` – Mark Jeronimus Jul 05 '22 at 11:20
  • 1
    Instead of all that, just use `echo -e` so that you can write `\n` for newlines: `echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' | sudo tee /etc/apt/apt.conf.d/999norecommend` – Jivan Pal Aug 15 '22 at 20:22