I'm writing a Makefile for our team to be able to set up a local environment with all of the software they need to install packages, etc so that they can develop quickly without having to figure out which software to install. Our repository has a PACKAGES file that has all of the required ubuntu packages that can be installed with this little gem:

[unix]$ sudo dpkg --set-selections < PACKAGES
[unix]$ sudo apt-get -u dselect-upgrade

This is great because its easy for everyone to get their environment set up by putting this in a Makefile. The challenge is how to restore their environment when the project is done. How do you uninstall all of the PACKAGES (and their unused dependencies) if you want to clean the environment? Is there an equivalent approach to remove a list of packages from the command line?


Like so...

sudo apt-get remove $(cat packages.txt)
  • But how do you determine if any of the packages in the file was not already installed on the system or added later from another bit of software? Removing it might break other programs ;) You probably need to remove them one at the time and also check if you can delete them without un-installing any other program.
  • good point on not removing the software if it was already installed. was hoping to avoid the cat call, but thanks! – dino May 14 '13 at 21:47
  • It's an overhead to go and create a packages.txt file. Is there a simple method like apt-get remove package1 package2 package3? I'm sure apt-get must have some of this basic capabilities that yum on RedHat systems has been able to do for decades.. – shailenTJ Nov 26 '18 at 18:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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