The Bloated Server Problem
Over months or years of using an Ubuntu Linux server, it is incredibly easy to lose track of exactly what software you have installed. You might have tested five different database engines, installed dozens of python libraries, and compiled various networking tools, only to leave them running silently in the background long after you stopped using them. This not only consumes valuable hard drive space but also expands the attack surface area of your server, creating severe security vulnerabilities. Before you can begin cleaning up your system, you need a complete, accurate inventory of every single package currently installed on the machine.
Using the apt list Command
The easiest way to generate this inventory is by using Ubuntu’s built-in Advanced Package Tool (APT).
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- Type the following command:
apt list --installed- Press Enter.
Managing the Massive Output
The terminal will instantly spit out a massive, scrolling list of hundreds (or thousands) of packages, making it completely impossible to read. To make this data actually useful, you need to format it.
- Method 1: Search for a specific app. If you just want to see if Apache is installed, you can pipe the output into the
grepcommand to filter it:apt list --installed | grep apache - Method 2: Read it slowly. If you want to scroll through the list manually, one page at a time, pipe the output into the
lesscommand:apt list --installed | less(Use the Spacebar to page down, and press ‘Q’ to quit). - Method 3: Export it to a text file. This is the best method for auditing a server. You can redirect the entire output into a simple text file that you can download or open in a text editor:
apt list --installed > installed_software.txt
You can now open installed_software.txt and carefully review every package your system is running.