Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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'm setting up an automated "no questions asked" preseed system and using Dustin Kirkland's server preseed as an example.

He uses the following line to install three packages as part of the automated install:

d-i pkgsel/include string byobu vim openssh-server

I am looking for the inverse of this, basically be able to remove packages as part of the automated install.

I am thinking I need to to use d-i preseed/late_command string apt-remove packagename to clean up stuff I don't want when the install is done, but I am not sure

share|improve this question
Definitely how I would go about it. Not big on preseed though. I use pseudopackages and start from a base install that doesn't have anything I don't want. – RobotHumans Jul 28 '11 at 12:04
No one from the desktop team or server team looked at this question? – Manish Sinha Oct 3 '11 at 19:24
I've tried this approach to remove packages but it is not working for me :(. – Maverick Sep 8 '14 at 14:27
up vote 10 down vote accepted

There isn't an option to purge o delete a package in the preseed configuration script but you can use this command....

d-i preseed/late_command

This command is run just before the install finishes, but when there is
still a usable /target directory. You can chroot to /target and use it
directly, or use the apt-install and in-target commands to easily install
packages and run commands in the target system.
"in-target" means: chroot /target
d-i preseed/late_command string [in-target] foo

example :

d-i preseed/late_command string \
            in-target apt-get remove packagename

you can also run a script :

d-i preseed/late_command string \
        in-target wget http://........./ -O /root/; \
        in-target /bin/bash /root/

or install a group of DEB files :

d-i preseed/late_command               string \
    for deb in /hd-media/*.deb; do cp $deb /target/tmp; \
    chroot /target dpkg -i /tmp/$(basename $deb); done
share|improve this answer

The example pressed is just an example; it does not contain all possible d-i combinations, but just those more common.

Personally, I have never tried to remove packages from an install, so I am not sure there is a specific d-i command for it; it sounds like your d-i preseed late_command should work. A quick search on the d-i docs did not produce anything... But, of course, Colin would know ;-)

Alternatively, you could start from a basic server, and then add whatever you want:

tasksel tasksel/first   multiselect     Basic Ubuntu server
d-i preseed/late_command string apt-install whatever else
share|improve this answer

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.