Ubuntu/Lubuntu (Linux) - Clean hard drive, remove unnecessary files
Every hard drive will eventually fill up. If you don't want to buy a new hard drive, which is expensive and time-consuming, you can clean up your Linux system to create more hard drive space. Find out in this article what options there are for doing this under Linux (Ubuntu, Lubuntu, etc.).
1. Remove unnecessary Linux kernels
With every Linux kernel update, the previous kernel is not automatically removed, but remains in case the new kernel does not work correctly. Experience shows, however, that the previous kernel is never needed again. This is almost always the case if the system works properly for a certain period after a kernel update. Therefore, experience shows that kernels that are no longer needed can be removed.
Use the following command to remove all kernels that are no longer needed. This only applies to kernels installed via updates, not kernels installed manually.
$ apt-get autoremove --purge
To see which kernels are installed, you can use the following command:
$ dpkg --list | grep linux-image
3. Programme/Pakete entfernen/deinstallieren
In Linux, packages are dependent on programs and Linux system programs. If packages required by these programs are removed, the program or system will no longer work. Therefore, only packages that are really no longer needed should be removed. Removing standard programs such as Firefox, nano, etc. should not pose any problems.
As an example, python3 was uninstalled. The result was that the system no longer started. The following message appeared:
: unable to launch "/user/bin/lxsession -s Lubuntu -e LXDE" X session --- "/user/bin/lxsession -s Lubuntu -e LXDE" not found; falling back to default session.
With this command, packages/programs can be specifically removed under Linux:
$ apt-get remove paket1 paket2
$ apt-get remove firefox
Command to see which packages/programs are installed:
$ apt list --installed
This function can be used to list packages with specific names. e.g. for Python: pyth*
$ dpkg --list | grep pyth
3. Clear APT cache (memory)
Ubuntu and Lubuntu save all downloads in the cache so that they do not have to be downloaded again and again. This data is of course no longer needed if everything is installed as desired. This means that the cache can always be emptied. The following command empties the cache:
$ apt-get clean
To see how much cache memory is used, this command can be used:
$ du -sh /var/cache/apt/archives