Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that downloads and replaces kernel headers in Debian squeeze.

function fixHeaders(){
    #Replace the kernel headers from OVH with standard kernel headers...
    aptitude -y install linux-image-2.6.32-5-amd64  
    sed s/'GRUB_DEFAULT=0'/'GRUB_DEFAULT=1'/g
    echo "Rebooting the machine. Run this script again after reboot and choose option 2."
    sleep 1

The problem I'm having is that after aptitude downloads the package it throws the script into a text gui and asks the user a bunch of questions. Is there any way to skip this or send tab/enter at the appropriate times to select "OK" for all answers?

share|improve this question
I am not sure if it works in your case, but setting DEBIAN_FRONTEND = noninteractive works for debian/ubuntu release upgrades. – Daniel t. Feb 13 '13 at 17:06

Beware that this answer I quote will not get rid of all dialogues, it will still display what APT/DPKG deems critical. Perhaps it's best to experiment with the second option + using the readline frontend for debconf and to prepare an answer file.

Quoting from a sister site:

This should do what you asked; asking the config questions afterward:

$ apt-get upgrade
# Wait a long time.   Should be almost entirely noninteractive.
$ dpkg-reconfigure --default-priority=medium --unseen-only

Alternatively you could try asking all the config questions before:

$ apt-get clean
$ cat >> /etc/apt/apt.conf <<EOF
// Pre-configure all packages before
// they are installed.
DPkg::Pre-Install-Pkgs {
    "dpkg-preconfigure --apt --priority=low";
$ apt-get upgrade
share|improve this answer
apt-get upgrade will not work in my situation. I'm replacing kernel headers, not upgrading the kernel to a new version, but selecting a different version. – 에이바 Feb 13 '13 at 17:33
I quoted the answer as is. This works with apt-get install as well as dpkg-configure will be called either way. – fuero Feb 13 '13 at 17:35
That still prompts the user to answer questions, which they will not see as that part of the script runs within a function -- I could change it but the person running the script (who is not me) will not understand. I was really looking for an automated solution. – 에이바 Feb 13 '13 at 17:49
up vote 4 down vote accepted

Based on Daniel t's comment I was able to do this with DEBIAN_FRONTEND=noninteractive

DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get install -y -q --force-yes linux-image-2.6.32-5-amd64 
share|improve this answer
You should also investigate preseeding the packages. This permits you to answer the questions before they are even asked. – Zoredache Feb 13 '13 at 17:51
Very interesting, thanks for the link. – 에이바 Feb 13 '13 at 17:54

You can send whatever you want with the tool expect, given that you can identify the "appropriate times" (because the input doesn't change).

share|improve this answer
The amount of times to hit "OK" does vary depending on the machine and its configurations. – 에이바 Feb 13 '13 at 17:30
That alone would probably not be a problem as long as it is possible to correctly recognize the questions (or the end of the questions). – Hauke Laging Feb 13 '13 at 17:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.