सामग्री पर जाएँ
Ubuntu / Linux

Free Up Disk Space on Ubuntu: Clean Unused Packages with apt autoremove

Run sudo apt autoremove --purge, then sudo apt clean. Check the result with df -h.

परखा गया Ubuntu 24.04 LTS, 22.04 LTS

Every install and upgrade leaves something behind: libraries pulled in as dependencies, old kernels and downloaded .deb files. On small cloud servers that can fill /boot or the root disk. Ubuntu’s package manager can clean it up safely.

Step 1 – Check what will be removed

Terminal
df -h /nsudo apt autoremove u002du002ddry-run

Read the list. It should contain only packages that were installed automatically and are no longer needed by anything.

Step 2 – Remove unused packages

Terminal
sudo apt autoremove u002du002dpurge

--purge also removes their leftover configuration files. Confirm with Y.

Step 3 – Clear the package cache

Terminal
sudo apt clean

This deletes downloaded installers in /var/cache/apt/archives; apt downloads them again if ever needed.

Step 4 – Optional: shrink old logs

Terminal
journalctl u002du002ddisk-usagensudo journalctl u002du002dvacuum-time=14d

Step 5 – See what you saved

Terminal
df -h /

Read before you confirm

If autoremove proposes removing something you use (for example after you uninstalled a meta-package), mark it as manually installed first: sudo apt-mark manual <package>. On shared servers, review the list carefully – removing a library another site depends on breaks it.

Make it routine

Run sudo apt update && sudo apt upgrade && sudo apt autoremove --purge during regular maintenance, or put it in a script with logging.

Inder Kochar

लेखक

Inder Kochar

सिस्टम्स और नेटवर्क इंजीनियर – मैं वही समाधान लिखता हूँ जो क्लाइंट्स के साथ इस्तेमाल करता हूँ, असली सिस्टम पर परखे हुए। ऐसी ही किसी समस्या में फँसे हैं?

आगे पढ़ें

सवाल पूछें या अपना समाधान बताएँ

आपका ईमेल प्रकाशित नहीं होगा। टिप्पणियाँ जाँची जाती हैं – कृपया विषय से जुड़ी रखें।