Make apt ignore a single recommendation

Solution 1:

Install vim:

sudo apt install vim

Install vim without recommends:

sudo apt install --no-install-recommends vim

Install vim with recommends except xz-utils:

sudo apt install vim xz-utils-

Solution 2:

When you say you want to automate it, I'm assuming you mean you wish to install owncloud on many machines but never install libreoffice-writer (and all its dependencies).

If that's the case, then you want to make use of Apt Pinning. This lets you specify specific versions of packages, including no version at all.

Per this question on AskUbuntu the way to do this is to add the following to /etc/apt/preferences:

Package: libreoffice-writer
Pin: origin ""
Pin-Priority: -1

If you need to do this totally automatically (such as in a single ssh command) you could just echo that into the file before doing the install. That'd look something like this:

echo 'Package: libreoffice-writer\nPin: origin ""\nPin-Priority: -1' >> /etc/apt/preferences && apt-get install owncloud