Ubuntu – Question regarding removing source files after building

aptcompilingdependenciespackage-management

I've been building a lot of software from source as I've been wanting to learn it for quite a while now. The following happens:

  1. Download source files (normally a tarball file)
  2. Install dependencies (normally a bunch of libraries)
  3. Configure, build and either install or just run

I am still confused as to what files relate to what etc. so my question might appear as stupid.

I have 128gb of ssd hard drive space. This is not a lot for me. I need every single bit!

When building from source it compiles the file into a so called dist folder which can then be run (or installed). So my question is:

  • As I assume the source files are not needed since I built the software, how do I remove these files safely?

Best Answer

In most cases (source files are not consistent), you can remove the source files, tarball etc if you want. This however may make it difficult to remove the software depending on how you installed it, and the software itself.

If you used checkinstall, or don't think you want to remove the packages later, you can delete the source tarball(s) and free up space easily. If not, see below.

Tarball installers generally work by building anything they need to build, and then copying/moving the files to where they need to be. Some also are helpful by deleting temporary build files after compiling, and/or make a list of what was installed (which often is needed to uninstall, and is why you might not want to delete those files). Anyway some installers may have a uninstall option - e.g. to reverse sudo make install:

sudo make uninstall

This varies by installers, you can see if it supports by reading the documentation of the software (this should be included with the package), or by examining the uninstall file. So if you need to use the uninstall option, you may want to keep the source files. They should not be necessary to run most programs normally.

N.B. You probably can also remove some of the dependencies (the devel packages etc) as those may have only been needed for compiling the software, you don't need them to run it. To free up space generally you can also use the autoremove option with the apt-get command to remove unneeded dependcies.

Related Question