Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Ubuntu server with the default package list installed. I'd like to uninstall everything that isn’t nginx, its dependencies, and any other packages required to boot to a tty and run nginx.

Is there a way to do this without manually discerning which packages to remove?

Aside: my reason to do this is so the system has as few tools installed as possible in case of exploits in nginx etc.

Edit: I will also need sshd, and sudo… maybe a good answer will point out other things I will likely need.

share|improve this question
1  
look at it other way around: install minimal server and add required packages help.ubuntu.com/community/Installation/MinimalCD –  tigran May 8 '13 at 15:17
    
A good suggestion, and I’ll do that if I have to. But as it stands, I’ve not the time. –  Max Howell May 8 '13 at 15:18

1 Answer 1

The system wouldn't allow you to remove sudo without a fight, just like it wouldn't let you remove your kernel or the apt tools themselves. One problem is that your question mixes two problems: (1) what is the set of packages that are minimally required for nginx as apt dependencies and (2) what is a sane minimal set of packages for a healthy working system.

As an example, nginx probably may not depend in any libapt sense on sshd, but you don't want to remove ssh from a remote server. I actually think @tigran's answer is safest and quickest. You can install a minimal system in minutes, and this question has already been here a half-hour.

Other than that, I would suggest that aptitude has very powerful search and matching options. You could probably craft a command line like this:

aptitude purge $(aptitude search <not-depended-on-by-nginx> and <not-essential>)

But again, getting such a command just right might very well take longer than installing a minimal system and setting it running.

share|improve this answer

Your Answer

 
discard

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.