Score:3

How to do apt upgrade with noninteractive?

cn flag

I want make Ubuntu 18.04 server (text only) upgrade itself and keep original configure in a bash script. I tried

apt update && apt upgrade -y

and

apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

and

apt upgrade --yes --force-yes

and

export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes

ALL not working which means they all ask for interactive.

Pizza avatar
in flag
"ALL not working", but what exactly is your output? Are you receiving any errors? Might be something else that fails your attempts? Also as @sudodus asked - what version and flavor of Ubuntu are you running?
it flag
Related: https://askubuntu.com/questions/972516/debian-frontend-environment-variable
Score:3
cn flag

Finally I make a script that works.
This will try upgrade everything and keep the configuration file,
Only safe for flash installed box.

#!/bin/bash
sudo apt update -y
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" dist-upgrade -q -y --allow-downgrades --allow-remove-essential --allow-change-held-packages
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.